Skip to content

Commit 294cd40

Browse files
committed
fix(popover): fix improper first placment on React 18
1 parent 0a46d99 commit 294cd40

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- `IconButton`: remove the children prop as it's not actually supported by the component
13+
- `Popover`: fix improper first placement on React 18
1314

1415
## [3.11.0][] - 2025-02-05
1516

packages/lumx-react/src/components/popover/Popover.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import classNames from 'classnames';
66
import { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';
77
import { useFocus } from '@lumx/react/hooks/useFocus';
88
import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
9-
import { DOCUMENT } from '@lumx/react/constants';
9+
import { DOCUMENT, VISUALLY_HIDDEN } from '@lumx/react/constants';
1010
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
1111
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
1212
import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
@@ -168,6 +168,8 @@ const _InnerPopover = forwardRef<PopoverProps, HTMLDivElement>((props, ref) => {
168168
elevation: Math.min(elevation || 0, 5),
169169
position,
170170
}),
171+
// Do not show the popover while it's not properly placed
172+
!styles.popover?.transform ? VISUALLY_HIDDEN : undefined,
171173
)}
172174
style={styles.popover}
173175
{...attributes.popper}

packages/lumx-react/src/components/popover/usePopoverStyle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export function usePopoverStyle({
103103
zIndex,
104104
}: Options): Output {
105105
const [popperElement, setPopperElement] = useState<null | HTMLElement>(null);
106-
107106
const [arrowElement, setArrowElement] = useState<null | HTMLElement>(null);
108107

109108
const actualOffset: [number, number] = [offset?.along ?? 0, (offset?.away ?? 0) + (hasArrow ? ARROW_SIZE : 0)];
@@ -152,6 +151,7 @@ export function usePopoverStyle({
152151

153152
return newStyles;
154153
}, [style, styles.popper, zIndex, fitWithinViewportHeight]);
154+
155155
return {
156156
styles: { arrow: styles.arrow, popover: popoverStyle },
157157
attributes,

0 commit comments

Comments
 (0)