Skip to content

Commit 02960b1

Browse files
committed
Fix arrow position when Tooltip is auto-positioned to the left
1 parent 793018f commit 02960b1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/bento-design-system/src/Tooltip/Tooltip.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ export function Tooltip(props: Props) {
3636
const config = useBentoConfig().tooltip;
3737
const arrowRef = useRef<HTMLElement | null>(null);
3838

39-
const commonMiddleware = [shift(), offset(8), arrow({ element: arrowRef })];
39+
const commonMiddleware = [shift(), offset(8)];
40+
const arrowMiddleware = arrow({ element: arrowRef });
4041
const floatingProps: UseFloatingProps = props.placement
4142
? {
4243
placement: props.placement,
43-
middleware: commonMiddleware.concat([flip()]),
44+
middleware: commonMiddleware.concat([flip(), arrowMiddleware]),
4445
}
4546
: {
46-
middleware: commonMiddleware.concat([autoPlacement()]),
47+
// NOTE(gabro): it's important that arrow comes after autoPlacement, otherwise the arrow will be positioned incorrectly
48+
// See https://github.com/buildo/bento-design-system/issues/513
49+
middleware: commonMiddleware.concat([autoPlacement(), arrowMiddleware]),
4750
};
4851
const {
4952
x,

0 commit comments

Comments
 (0)