Skip to content

Commit 3ab9d54

Browse files
committed
feat(tooltip): increment z-index above popover default z-index
1 parent 2f77d32 commit 3ab9d54

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Added
1616

17-
- `Tooltip`: Add `closeMode` to hide the tooltip instead of unmounting it
18-
- `Tooltip`: Add `ariaLinkMode` to use tooltip as label instead of description
17+
- `Tooltip`: add `closeMode` to hide the tooltip instead of unmounting it.
18+
- `Tooltip`: add `ariaLinkMode` to use tooltip as label instead of description.
19+
20+
### Changed
21+
22+
- `Tooltip`: increment z-index making them appear above popovers.
1923

2024
## [3.9.1][] - 2024-09-17
2125

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { skipRender } from '@lumx/react/utils/skipRender';
1515

1616
import { useRestoreFocusOnClose } from './useRestoreFocusOnClose';
1717
import { usePopoverStyle } from './usePopoverStyle';
18-
import { Elevation, FitAnchorWidth, Offset, Placement } from './constants';
18+
import { Elevation, FitAnchorWidth, Offset, Placement, POPOVER_ZINDEX } from './constants';
1919

2020
/**
2121
* Defines the props of the component.
@@ -88,7 +88,7 @@ const DEFAULT_PROPS: Partial<PopoverProps> = {
8888
placement: Placement.AUTO,
8989
focusAnchorOnClose: true,
9090
usePortal: true,
91-
zIndex: 9999,
91+
zIndex: POPOVER_ZINDEX,
9292
};
9393

9494
/** Method to render the popover inside a portal if usePortal is true */

packages/lumx-react/src/components/popover/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ export type FitAnchorWidth = ValueOf<typeof FitAnchorWidth>;
5555
* Arrow size (in pixel).
5656
*/
5757
export const ARROW_SIZE = 14;
58+
59+
/**
60+
* Popover default z-index
61+
*/
62+
export const POPOVER_ZINDEX = 9999;

packages/lumx-react/src/components/tooltip/Tooltip.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { TooltipContextProvider } from '@lumx/react/components/tooltip/context';
1313
import { useId } from '@lumx/react/hooks/useId';
1414
import { usePopper } from '@lumx/react/hooks/usePopper';
1515

16-
import { ARIA_LINK_MODES } from '@lumx/react/components/tooltip/constants';
16+
import { ARIA_LINK_MODES, TOOLTIP_ZINDEX } from '@lumx/react/components/tooltip/constants';
1717
import { useInjectTooltipRef } from './useInjectTooltipRef';
1818
import { useTooltipOpen } from './useTooltipOpen';
1919

@@ -55,6 +55,7 @@ const DEFAULT_PROPS: Partial<TooltipProps> = {
5555
placement: Placement.BOTTOM,
5656
closeMode: 'unmount',
5757
ariaLinkMode: 'aria-describedby',
58+
zIndex: TOOLTIP_ZINDEX,
5859
};
5960

6061
/**
@@ -70,8 +71,18 @@ const ARROW_SIZE = 8;
7071
* @return React element.
7172
*/
7273
export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, ref) => {
73-
const { label, children, className, delay, placement, forceOpen, closeMode, ariaLinkMode, ...forwardedProps } =
74-
props;
74+
const {
75+
label,
76+
children,
77+
className,
78+
delay,
79+
placement,
80+
forceOpen,
81+
closeMode,
82+
ariaLinkMode,
83+
zIndex,
84+
...forwardedProps
85+
} = props;
7586
// Disable in SSR.
7687
if (!DOCUMENT) {
7788
return <>{children}</>;
@@ -131,7 +142,7 @@ export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, re
131142
hidden: !isOpen && closeMode === 'hide',
132143
}),
133144
)}
134-
style={styles.popper}
145+
style={{ ...styles.popper, zIndex }}
135146
{...attributes.popper}
136147
>
137148
<div className={`${CLASSNAME}__arrow`} />
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1+
import { POPOVER_ZINDEX } from '../popover/constants';
2+
13
export const ARIA_LINK_MODES = ['aria-describedby', 'aria-labelledby'] as const;
4+
5+
/**
6+
* Make sure tooltip appear above popovers.
7+
*/
8+
export const TOOLTIP_ZINDEX = POPOVER_ZINDEX + 1;

0 commit comments

Comments
 (0)