@navikt/ds-react 7.33.0 → 7.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +0 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/cjs/overlays/action-menu/ActionMenu.js +2 -5
- package/cjs/overlays/action-menu/ActionMenu.js.map +1 -1
- package/cjs/overlays/dismissablelayer/DismissableLayer.d.ts +3 -30
- package/cjs/overlays/dismissablelayer/DismissableLayer.js +141 -134
- package/cjs/overlays/dismissablelayer/DismissableLayer.js.map +1 -1
- package/cjs/overlays/dismissablelayer/util/sort-layers.d.ts +18 -0
- package/cjs/overlays/dismissablelayer/util/sort-layers.js +51 -0
- package/cjs/overlays/dismissablelayer/util/sort-layers.js.map +1 -0
- package/cjs/overlays/floating-menu/Menu.d.ts +5 -7
- package/cjs/overlays/floating-menu/Menu.js +7 -15
- package/cjs/overlays/floating-menu/Menu.js.map +1 -1
- package/cjs/popover/Popover.js +0 -1
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/portal/Portal.d.ts +1 -3
- package/cjs/portal/Portal.js +49 -17
- package/cjs/portal/Portal.js.map +1 -1
- package/cjs/tooltip/Tooltip.js +23 -22
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/cjs/util/focus-boundary/FocusBoundary.d.ts +19 -10
- package/cjs/util/focus-boundary/FocusBoundary.js +107 -63
- package/cjs/util/focus-boundary/FocusBoundary.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +0 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/overlays/action-menu/ActionMenu.js +2 -5
- package/esm/overlays/action-menu/ActionMenu.js.map +1 -1
- package/esm/overlays/dismissablelayer/DismissableLayer.d.ts +3 -30
- package/esm/overlays/dismissablelayer/DismissableLayer.js +140 -132
- package/esm/overlays/dismissablelayer/DismissableLayer.js.map +1 -1
- package/esm/overlays/dismissablelayer/util/sort-layers.d.ts +18 -0
- package/esm/overlays/dismissablelayer/util/sort-layers.js +49 -0
- package/esm/overlays/dismissablelayer/util/sort-layers.js.map +1 -0
- package/esm/overlays/floating-menu/Menu.d.ts +5 -7
- package/esm/overlays/floating-menu/Menu.js +7 -15
- package/esm/overlays/floating-menu/Menu.js.map +1 -1
- package/esm/popover/Popover.js +0 -1
- package/esm/popover/Popover.js.map +1 -1
- package/esm/portal/Portal.d.ts +1 -3
- package/esm/portal/Portal.js +50 -18
- package/esm/portal/Portal.js.map +1 -1
- package/esm/tooltip/Tooltip.js +23 -22
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/util/focus-boundary/FocusBoundary.d.ts +19 -10
- package/esm/util/focus-boundary/FocusBoundary.js +108 -64
- package/esm/util/focus-boundary/FocusBoundary.js.map +1 -1
- package/package.json +3 -3
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +0 -1
- package/src/overlays/action-menu/ActionMenu.tsx +2 -4
- package/src/overlays/dismissablelayer/DismissableLayer.tsx +219 -194
- package/src/overlays/dismissablelayer/util/sort-layers.test.ts +128 -0
- package/src/overlays/dismissablelayer/util/sort-layers.ts +61 -0
- package/src/overlays/floating-menu/Menu.tsx +11 -21
- package/src/popover/Popover.tsx +0 -1
- package/src/portal/Portal.tsx +89 -31
- package/src/tooltip/Tooltip.tsx +4 -4
- package/src/util/focus-boundary/FocusBoundary.tsx +164 -93
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { getSortedLayers } from "./sort-layers";
|
|
3
|
+
|
|
4
|
+
type DismissableLayerElement = HTMLDivElement;
|
|
5
|
+
|
|
6
|
+
describe("DismissableLayer: getSortedLayers", () => {
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
/* Reset id counter before tests to ensure consistent element ids */
|
|
9
|
+
idCounter = 0;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("should return empty array when no layers", () => {
|
|
13
|
+
const layers = new Set<DismissableLayerElement>();
|
|
14
|
+
const branchedLayers = new Map();
|
|
15
|
+
|
|
16
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
17
|
+
expect(result).toEqual([]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("should return single layer", () => {
|
|
21
|
+
const layer = createTestElement();
|
|
22
|
+
const layers = new Set([layer]);
|
|
23
|
+
const branchedLayers = new Map();
|
|
24
|
+
|
|
25
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
26
|
+
expect(result).toEqual([layer]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("should return multiple independent layers in order", () => {
|
|
30
|
+
const layer1 = createTestElement();
|
|
31
|
+
const layer2 = createTestElement();
|
|
32
|
+
const layer3 = createTestElement();
|
|
33
|
+
const layers = new Set([layer1, layer2, layer3]);
|
|
34
|
+
const branchedLayers = new Map();
|
|
35
|
+
|
|
36
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
37
|
+
expect(result).toEqual([layer1, layer2, layer3]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("should sort parent before child", () => {
|
|
41
|
+
const parent = createTestElement();
|
|
42
|
+
const child = createTestElement();
|
|
43
|
+
const layers = new Set([child, parent]);
|
|
44
|
+
const branchedLayers = new Map([[parent, new Set([child])]]);
|
|
45
|
+
|
|
46
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
47
|
+
expect(result).toEqual([parent, child]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("should handle nested parent-child relationships", () => {
|
|
51
|
+
const grandparent = createTestElement();
|
|
52
|
+
const parent = createTestElement();
|
|
53
|
+
const child = createTestElement();
|
|
54
|
+
const layers = new Set([child, parent, grandparent]);
|
|
55
|
+
const branchedLayers = new Map([
|
|
56
|
+
[grandparent, new Set([parent])],
|
|
57
|
+
[parent, new Set([child])],
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
61
|
+
expect(result).toEqual([grandparent, parent, child]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("should handle multiple children of same parent", () => {
|
|
65
|
+
const parent = createTestElement();
|
|
66
|
+
const child1 = createTestElement();
|
|
67
|
+
const child2 = createTestElement();
|
|
68
|
+
const layers = new Set([child1, child2, parent]);
|
|
69
|
+
const branchedLayers = new Map([[parent, new Set([child1, child2])]]);
|
|
70
|
+
|
|
71
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
72
|
+
expect(result[0]).toBe(parent);
|
|
73
|
+
expect(result.slice(1)).toContain(child1);
|
|
74
|
+
expect(result.slice(1)).toContain(child2);
|
|
75
|
+
expect(result).toHaveLength(3);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("should handle complex branched structure", () => {
|
|
79
|
+
const root = createTestElement();
|
|
80
|
+
const branch1 = createTestElement();
|
|
81
|
+
const branch2 = createTestElement();
|
|
82
|
+
const leaf1 = createTestElement();
|
|
83
|
+
const leaf2 = createTestElement();
|
|
84
|
+
|
|
85
|
+
const layers = new Set([root, branch1, branch2, leaf1, leaf2]);
|
|
86
|
+
const branchedLayers = new Map([
|
|
87
|
+
[root, new Set([branch1, branch2])],
|
|
88
|
+
[branch1, new Set([leaf1])],
|
|
89
|
+
[branch2, new Set([leaf2])],
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
93
|
+
expect(result[0]).toBe(root);
|
|
94
|
+
expect(result.indexOf(branch1)).toBeLessThan(result.indexOf(leaf1));
|
|
95
|
+
expect(result.indexOf(branch2)).toBeLessThan(result.indexOf(leaf2));
|
|
96
|
+
expect(result).toHaveLength(5);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("should ignore self-referential children", () => {
|
|
100
|
+
const layer = createTestElement();
|
|
101
|
+
const layers = new Set([layer]);
|
|
102
|
+
const branchedLayers = new Map([[layer, new Set([layer])]]);
|
|
103
|
+
|
|
104
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
105
|
+
expect(result).toEqual([layer]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("should handle mixed independent and branched layers", () => {
|
|
109
|
+
const independent = createTestElement();
|
|
110
|
+
const parent = createTestElement();
|
|
111
|
+
const child = createTestElement();
|
|
112
|
+
const layers = new Set([independent, parent, child]);
|
|
113
|
+
const branchedLayers = new Map([[parent, new Set([child])]]);
|
|
114
|
+
|
|
115
|
+
const result = getSortedLayers(layers, branchedLayers);
|
|
116
|
+
expect(result).toContain(independent);
|
|
117
|
+
expect(result.indexOf(parent)).toBeLessThan(result.indexOf(child));
|
|
118
|
+
expect(result).toHaveLength(3);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
let idCounter = 0;
|
|
123
|
+
|
|
124
|
+
function createTestElement() {
|
|
125
|
+
const element = document.createElement("div");
|
|
126
|
+
element.id = `layer-${idCounter++}`;
|
|
127
|
+
return element;
|
|
128
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
type DismissableLayerElement = HTMLDivElement;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns an array of layers sorted such that parents appear before their children.
|
|
5
|
+
*
|
|
6
|
+
* **Why**:
|
|
7
|
+
* - mount order for parent-child relationships is unstable due to portals
|
|
8
|
+
* - event handling relies on parents being before children in the array
|
|
9
|
+
*
|
|
10
|
+
* This function ensures that for any parent-child relationship, the parent layer
|
|
11
|
+
* will always appear before its child layer in the returned array,
|
|
12
|
+
* resulting in consistent behavior.
|
|
13
|
+
*
|
|
14
|
+
* @param layers - A set of DismissableLayerElements to be sorted.
|
|
15
|
+
* @param branchedLayers - A map where each key is a parent layer and its value is a set of child layers.
|
|
16
|
+
* @returns An array of DismissableLayerElements sorted by parent-child relationships.
|
|
17
|
+
*/
|
|
18
|
+
function getSortedLayers(
|
|
19
|
+
layers: Set<DismissableLayerElement>,
|
|
20
|
+
branchedLayers: Map<DismissableLayerElement, Set<DismissableLayerElement>>,
|
|
21
|
+
): DismissableLayerElement[] {
|
|
22
|
+
const sorted: DismissableLayerElement[] = [];
|
|
23
|
+
const visited = new Set<DismissableLayerElement>();
|
|
24
|
+
const parentMap = new Map<DismissableLayerElement, DismissableLayerElement>();
|
|
25
|
+
|
|
26
|
+
branchedLayers.forEach((children, parent) => {
|
|
27
|
+
children.forEach((child) => {
|
|
28
|
+
if (child !== parent) {
|
|
29
|
+
parentMap.set(child, parent);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const walk = (layer: DismissableLayerElement) => {
|
|
35
|
+
if (visited.has(layer)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const parent = parentMap.get(layer);
|
|
40
|
+
if (parent && !visited.has(parent)) {
|
|
41
|
+
walk(parent);
|
|
42
|
+
if (visited.has(layer)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
visited.add(layer);
|
|
48
|
+
sorted.push(layer);
|
|
49
|
+
|
|
50
|
+
const children = branchedLayers.get(layer);
|
|
51
|
+
if (children) {
|
|
52
|
+
children.forEach(walk);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
layers.forEach(walk);
|
|
57
|
+
|
|
58
|
+
return sorted;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { getSortedLayers };
|
|
@@ -243,7 +243,7 @@ type DismissableLayerProps = React.ComponentPropsWithoutRef<
|
|
|
243
243
|
>;
|
|
244
244
|
|
|
245
245
|
type MenuContentInternalPrivateProps = {
|
|
246
|
-
|
|
246
|
+
initialFocus?: FocusScopeProps["initialFocus"];
|
|
247
247
|
onDismiss?: DismissableLayerProps["onDismiss"];
|
|
248
248
|
disableOutsidePointerEvents?: DismissableLayerProps["disableOutsidePointerEvents"];
|
|
249
249
|
};
|
|
@@ -254,11 +254,7 @@ interface MenuContentInternalProps
|
|
|
254
254
|
React.ComponentPropsWithoutRef<typeof Floating.Content>,
|
|
255
255
|
"dir" | "onPlaced"
|
|
256
256
|
> {
|
|
257
|
-
|
|
258
|
-
* Event handler called when auto-focusing after close.
|
|
259
|
-
* Can be prevented.
|
|
260
|
-
*/
|
|
261
|
-
onCloseAutoFocus?: FocusScopeProps["onUnmountAutoFocus"];
|
|
257
|
+
returnFocus?: FocusScopeProps["returnFocus"];
|
|
262
258
|
onEntryFocus?: RovingFocusProps["onEntryFocus"];
|
|
263
259
|
onEscapeKeyDown?: DismissableLayerProps["onEscapeKeyDown"];
|
|
264
260
|
onPointerDownOutside?: DismissableLayerProps["onPointerDownOutside"];
|
|
@@ -273,8 +269,8 @@ const MenuContentInternal = forwardRef<
|
|
|
273
269
|
>(
|
|
274
270
|
(
|
|
275
271
|
{
|
|
276
|
-
|
|
277
|
-
|
|
272
|
+
initialFocus,
|
|
273
|
+
returnFocus,
|
|
278
274
|
disableOutsidePointerEvents,
|
|
279
275
|
onEntryFocus,
|
|
280
276
|
onEscapeKeyDown,
|
|
@@ -301,13 +297,8 @@ const MenuContentInternal = forwardRef<
|
|
|
301
297
|
|
|
302
298
|
return (
|
|
303
299
|
<FocusBoundary
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
// `onEntryFocus` in control of focusing first item
|
|
307
|
-
event.preventDefault();
|
|
308
|
-
contentRef.current?.focus({ preventScroll: true });
|
|
309
|
-
})}
|
|
310
|
-
onUnmountAutoFocus={onCloseAutoFocus}
|
|
300
|
+
initialFocus={initialFocus ?? contentRef}
|
|
301
|
+
returnFocus={returnFocus}
|
|
311
302
|
/* Focus trapping is handled in `Floating.Content: onKeyDown */
|
|
312
303
|
trapped={false}
|
|
313
304
|
loop={false}
|
|
@@ -588,7 +579,7 @@ const MenuPortal = forwardRef<MenuPortalElement, MenuPortalProps>(
|
|
|
588
579
|
}
|
|
589
580
|
|
|
590
581
|
return (
|
|
591
|
-
<Portal
|
|
582
|
+
<Portal rootElement={rootElement} ref={ref}>
|
|
592
583
|
{children}
|
|
593
584
|
</Portal>
|
|
594
585
|
);
|
|
@@ -917,15 +908,14 @@ const MenuSubContent = forwardRef<
|
|
|
917
908
|
align="start"
|
|
918
909
|
side="right"
|
|
919
910
|
disableOutsidePointerEvents={false}
|
|
920
|
-
|
|
921
|
-
// when opening a submenu, focus content for keyboard users only
|
|
911
|
+
initialFocus={() => {
|
|
922
912
|
if (rootContext.isUsingKeyboardRef.current) {
|
|
923
|
-
ref.current
|
|
913
|
+
return ref.current;
|
|
924
914
|
}
|
|
925
|
-
|
|
915
|
+
return false;
|
|
926
916
|
}}
|
|
927
917
|
/* Since we manually focus Subtrigger, we prevent use of auto-focus */
|
|
928
|
-
|
|
918
|
+
returnFocus={false}
|
|
929
919
|
onEscapeKeyDown={composeEventHandlers(
|
|
930
920
|
props.onEscapeKeyDown,
|
|
931
921
|
(event) => {
|
package/src/popover/Popover.tsx
CHANGED
package/src/portal/Portal.tsx
CHANGED
|
@@ -1,53 +1,111 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
HTMLAttributes,
|
|
3
|
+
createContext,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useContext,
|
|
6
|
+
} from "react";
|
|
2
7
|
import ReactDOM from "react-dom";
|
|
3
8
|
import { useProvider } from "../provider/Provider";
|
|
4
|
-
import { Slot } from "../slot/Slot";
|
|
5
9
|
import { Theme, useThemeInternal } from "../theme/Theme";
|
|
6
|
-
import {
|
|
10
|
+
import { useClientLayoutEffect, useMergeRefs } from "../util/hooks";
|
|
7
11
|
|
|
8
|
-
interface
|
|
12
|
+
export interface PortalProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
13
|
/**
|
|
10
14
|
* An optional container where the portaled content should be appended.
|
|
11
15
|
*/
|
|
12
16
|
rootElement?: HTMLElement | null;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
const PortalContext = createContext<HTMLElement | null>(null);
|
|
16
20
|
|
|
17
21
|
export const Portal = forwardRef<HTMLDivElement, PortalProps>(
|
|
18
|
-
({ rootElement,
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
+
({ rootElement, children, ...restProps }, forwardedRef) => {
|
|
23
|
+
const providerRootElement = useProvider()?.rootElement;
|
|
24
|
+
|
|
25
|
+
const parentPortalNode = useContext(PortalContext);
|
|
26
|
+
|
|
27
|
+
const [containerElement, setContainerElement] = React.useState<
|
|
28
|
+
HTMLElement | ShadowRoot | null
|
|
29
|
+
>(null);
|
|
30
|
+
const [portalNode, setPortalNode] = React.useState<HTMLElement | null>(
|
|
31
|
+
null,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const containerRef = React.useRef<HTMLElement | ShadowRoot | null>(null);
|
|
22
35
|
|
|
23
|
-
const
|
|
36
|
+
const mergedRefs = useMergeRefs(forwardedRef, setPortalNode);
|
|
24
37
|
|
|
25
38
|
/**
|
|
26
|
-
*
|
|
27
|
-
* If a theme is present, we want to make sure that theme cascades to portaled element.
|
|
39
|
+
* We update container in effect to avoid SSR mismatches.
|
|
28
40
|
*/
|
|
41
|
+
useClientLayoutEffect(() => {
|
|
42
|
+
/* Wait for the container to be resolved if explicitly `null`. */
|
|
43
|
+
if ((rootElement ?? providerRootElement) === null) {
|
|
44
|
+
if (containerRef.current) {
|
|
45
|
+
containerRef.current = null;
|
|
46
|
+
setPortalNode(null);
|
|
47
|
+
setContainerElement(null);
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const resolvedContainer =
|
|
53
|
+
rootElement ??
|
|
54
|
+
parentPortalNode ??
|
|
55
|
+
providerRootElement ??
|
|
56
|
+
globalThis?.document?.body;
|
|
57
|
+
|
|
58
|
+
if (resolvedContainer === null) {
|
|
59
|
+
if (containerRef.current) {
|
|
60
|
+
containerRef.current = null;
|
|
61
|
+
setPortalNode(null);
|
|
62
|
+
setContainerElement(null);
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (containerRef.current !== resolvedContainer) {
|
|
68
|
+
containerRef.current = resolvedContainer;
|
|
69
|
+
setPortalNode(null);
|
|
70
|
+
setContainerElement(resolvedContainer);
|
|
71
|
+
}
|
|
72
|
+
}, [parentPortalNode, providerRootElement, rootElement]);
|
|
73
|
+
|
|
74
|
+
if (!containerElement) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return ReactDOM.createPortal(
|
|
79
|
+
<PortalDiv ref={mergedRefs} {...restProps} data-aksel-portal="">
|
|
80
|
+
<PortalContext.Provider value={portalNode}>
|
|
81
|
+
{children}
|
|
82
|
+
</PortalContext.Provider>
|
|
83
|
+
</PortalDiv>,
|
|
84
|
+
containerElement,
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
type PortalDivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
90
|
+
|
|
91
|
+
const PortalDiv = forwardRef<HTMLDivElement, PortalDivProps>(
|
|
92
|
+
(props: PortalDivProps, forwardedRef) => {
|
|
93
|
+
const themeContext = useThemeInternal(false);
|
|
94
|
+
|
|
29
95
|
if (themeContext?.isDarkside) {
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
root,
|
|
41
|
-
)
|
|
42
|
-
: null;
|
|
96
|
+
return (
|
|
97
|
+
<Theme
|
|
98
|
+
theme={themeContext?.theme}
|
|
99
|
+
asChild
|
|
100
|
+
hasBackground={false}
|
|
101
|
+
data-color={themeContext?.color}
|
|
102
|
+
>
|
|
103
|
+
<div ref={forwardedRef} {...props} />
|
|
104
|
+
</Theme>
|
|
105
|
+
);
|
|
43
106
|
}
|
|
44
107
|
|
|
45
|
-
return
|
|
46
|
-
? ReactDOM.createPortal(
|
|
47
|
-
<Component ref={ref} data-aksel-portal="" {...rest} />,
|
|
48
|
-
root,
|
|
49
|
-
)
|
|
50
|
-
: null;
|
|
108
|
+
return <div ref={forwardedRef} {...props} />;
|
|
51
109
|
},
|
|
52
110
|
);
|
|
53
111
|
|
package/src/tooltip/Tooltip.tsx
CHANGED
|
@@ -209,8 +209,8 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
209
209
|
>
|
|
210
210
|
{children}
|
|
211
211
|
</Slot>
|
|
212
|
-
|
|
213
|
-
{
|
|
212
|
+
{_open && (
|
|
213
|
+
<Portal rootElement={rootElement}>
|
|
214
214
|
<div
|
|
215
215
|
{...getFloatingProps({
|
|
216
216
|
...rest,
|
|
@@ -267,8 +267,8 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
267
267
|
/>
|
|
268
268
|
)}
|
|
269
269
|
</div>
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
</Portal>
|
|
271
|
+
)}
|
|
272
272
|
</>
|
|
273
273
|
);
|
|
274
274
|
},
|