Skip to content

Commit 677f06c

Browse files
authored
fix: popovers in ComboBox and Select (#848)
1 parent 1c2b44f commit 677f06c

File tree

14 files changed

+91
-1724
lines changed

14 files changed

+91
-1724
lines changed

.changeset/swift-colts-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Fix position of ComboBox and Select popovers.

src/components/fields/ComboBox/ComboBox.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
Styles,
3737
tasty,
3838
} from '../../../tasty';
39+
import { chainRaf } from '../../../utils/raf';
3940
import { generateRandomId } from '../../../utils/random';
4041
import {
4142
mergeProps,
@@ -867,17 +868,16 @@ function ComboBoxOverlay({
867868
popoverRef as any,
868869
);
869870

870-
// Update position when overlay opens
871+
// Update position when overlay opens or content changes
871872
useLayoutEffect(() => {
872-
if (isOpen) {
873-
// Use double RAF to ensure layout is complete before positioning
874-
requestAnimationFrame(() => {
875-
requestAnimationFrame(() => {
876-
updatePosition?.();
877-
});
878-
});
873+
if (isOpen && updatePosition) {
874+
// Use triple RAF to ensure layout is complete before positioning
875+
// This gives enough time for the DisplayTransition and content to render
876+
return chainRaf(() => {
877+
updatePosition();
878+
}, 3);
879879
}
880-
}, [isOpen, updatePosition]);
880+
}, [isOpen]);
881881

882882
// Extract primary placement direction for consistent styling
883883
const placementDirection = placement?.split(' ')[0] || direction;

src/components/fields/LegacyComboBox/LegacyComboBox.docs.mdx

Lines changed: 0 additions & 297 deletions
This file was deleted.

0 commit comments

Comments
 (0)