File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
src/components/fields/FilterPicker Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @cube-dev/ui-kit " : patch
3+ ---
4+
5+ Fix popover of FilterPicker to corretly flip on opening.
Original file line number Diff line number Diff line change @@ -895,7 +895,7 @@ export const FilterPicker = forwardRef(function FilterPicker<T extends object>(
895895 ) ;
896896 } ;
897897
898- const [ shouldUpdatePosition , setShouldUpdatePosition ] = useState ( false ) ;
898+ const [ shouldUpdatePosition , setShouldUpdatePosition ] = useState ( true ) ;
899899
900900 // The trigger is rendered as a function so we can access the dialog state
901901 const renderTrigger = ( state ) => {
@@ -943,8 +943,14 @@ export const FilterPicker = forwardRef(function FilterPicker<T extends object>(
943943 } ) ;
944944
945945 useEffect ( ( ) => {
946- // Disable the update of the position while the popover is open (with a delay) to avoid jumping
947- setShouldUpdatePosition ( ! state . isOpen ) ;
946+ // Allow initial positioning & flipping when opening, then lock placement after first frame
947+ if ( state . isOpen ) {
948+ setShouldUpdatePosition ( true ) ;
949+ const id = requestAnimationFrame ( ( ) => setShouldUpdatePosition ( false ) ) ;
950+ return ( ) => cancelAnimationFrame ( id ) ;
951+ } else {
952+ setShouldUpdatePosition ( true ) ;
953+ }
948954 } , [ state . isOpen ] ) ;
949955
950956 // Clear button logic
@@ -1032,7 +1038,7 @@ export const FilterPicker = forwardRef(function FilterPicker<T extends object>(
10321038 placement = "bottom start"
10331039 styles = { triggerStyles }
10341040 shouldUpdatePosition = { shouldUpdatePosition }
1035- shouldFlip = { shouldFlip }
1041+ shouldFlip = { shouldFlip && ! isPopoverOpen }
10361042 isDismissable = { true }
10371043 shouldCloseOnInteractOutside = { ( el ) => {
10381044 const menuTriggerEl = el . closest ( '[data-popover-trigger]' ) ;
You can’t perform that action at this time.
0 commit comments