-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: status sheet buttons and height adjustment (#303)
- Loading branch information
Showing
7 changed files
with
60 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
import type { MutableRefObject } from 'react'; | ||
import { useLayoutEffect } from 'react'; | ||
import { getRelativeContainer } from '../utils/elements.js'; | ||
import { useDefaultElementId } from './useDefaultElementId.js'; | ||
import { getScrollableContainer } from './useScrollableContainer.js'; | ||
|
||
// NOTE: this hook is implicitly tied to the widget height functionality in the | ||
// AppExpandedContainer, RelativeContainer and CssBaselineContainer components as defined in AppContainer.ts | ||
// CSS changes in those components can have implications for the functionality in this hook | ||
|
||
export const useSetContentHeight = ( | ||
ref: MutableRefObject<HTMLElement | undefined>, | ||
) => { | ||
const elementId = useDefaultElementId(); | ||
useLayoutEffect(() => { | ||
const scrollableContainer = getScrollableContainer(elementId); | ||
const relativeContainer = getRelativeContainer(elementId); | ||
if ( | ||
!scrollableContainer || | ||
!relativeContainer || | ||
!ref.current || | ||
ref.current?.clientHeight <= scrollableContainer?.clientHeight | ||
ref.current?.clientHeight <= relativeContainer?.clientHeight | ||
) { | ||
return; | ||
} | ||
scrollableContainer.style.height = `${ref.current.clientHeight}px`; | ||
relativeContainer.style.minHeight = `${ref.current.clientHeight}px`; | ||
return () => { | ||
scrollableContainer.style.removeProperty('height'); | ||
relativeContainer.style.removeProperty('min-height'); | ||
}; | ||
}, [elementId, ref]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters