Skip to content

Commit

Permalink
fix: ailabel autoalign was not working (#17659)
Browse files Browse the repository at this point in the history
* fix: ailabel autoalign was not working

* fix: added fallbackPlacements instead of shift

---------

Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com>
  • Loading branch information
preetibansalui and tay1orjones authored Oct 29, 2024
1 parent bfda636 commit 800efdd
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions packages/react/src/components/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,41 @@ export const Popover: PopoverComponent = React.forwardRef(
// Middleware order matters, arrow should be last
middleware: [
offset(!isTabTip ? popoverDimensions?.current?.offset : 0),
autoAlign && flip({ fallbackAxisSideDirection: 'start' }),
autoAlign &&
flip({
fallbackPlacements: align.includes('bottom')
? [
'bottom',
'bottom-start',
'bottom-end',
'right',
'right-start',
'right-end',
'left',
'left-start',
'left-end',
'top',
'top-start',
'top-end',
]
: [
'top',
'top-start',
'top-end',
'left',
'left-start',
'left-end',
'right',
'right-start',
'right-end',
'bottom',
'bottom-start',
'bottom-end',
],

fallbackStrategy: 'initialPlacement',
fallbackAxisSideDirection: 'start',
}),
arrow({
element: caretRef,
}),
Expand Down Expand Up @@ -567,7 +601,6 @@ function PopoverContentRenderFunction(
const ref = useMergedRefs([setFloating, forwardRef]);
const enableFloatingStyles =
useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;

return (
<span {...rest} className={`${prefix}--popover`}>
<span className={cx(`${prefix}--popover-content`, className)} ref={ref}>
Expand Down

0 comments on commit 800efdd

Please sign in to comment.