@lumx/react 3.7.1 → 3.7.2-alpha.0
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/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^3.7.
|
|
11
|
-
"@lumx/icons": "^3.7.
|
|
10
|
+
"@lumx/core": "^3.7.2-alpha.0",
|
|
11
|
+
"@lumx/icons": "^3.7.2-alpha.0",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.3.2",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"build:storybook": "storybook build"
|
|
113
113
|
},
|
|
114
114
|
"sideEffects": false,
|
|
115
|
-
"version": "3.7.
|
|
115
|
+
"version": "3.7.2-alpha.0"
|
|
116
116
|
}
|
|
@@ -24,10 +24,10 @@ jest.mock('@lumx/react/constants', () => ({
|
|
|
24
24
|
*/
|
|
25
25
|
const setup = async (propsOverride: Partial<TooltipProps> = {}) => {
|
|
26
26
|
const props: any = { forceOpen: true, label: 'Tooltip label', children: 'Anchor', ...propsOverride };
|
|
27
|
-
render(<Tooltip {...props} />);
|
|
27
|
+
const result = render(<Tooltip {...props} />);
|
|
28
28
|
const tooltip = screen.queryByRole('tooltip', { name: props.label });
|
|
29
29
|
const anchorWrapper = queryByClassName(document.body, 'lumx-tooltip-anchor-wrapper');
|
|
30
|
-
return { props, tooltip, anchorWrapper };
|
|
30
|
+
return { props, tooltip, anchorWrapper, result };
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
describe(`<${Tooltip.displayName}>`, () => {
|
|
@@ -136,6 +136,28 @@ describe(`<${Tooltip.displayName}>`, () => {
|
|
|
136
136
|
expect(lines[0]).toHaveTextContent('First line');
|
|
137
137
|
expect(lines[1]).toHaveTextContent('Second line');
|
|
138
138
|
});
|
|
139
|
+
|
|
140
|
+
it('should have a stable ref', async () => {
|
|
141
|
+
const ref = React.createRef() as any;
|
|
142
|
+
|
|
143
|
+
// Render without a label
|
|
144
|
+
const result = render(
|
|
145
|
+
<Tooltip label="">
|
|
146
|
+
<span ref={ref}>some text</span>
|
|
147
|
+
</Tooltip>,
|
|
148
|
+
);
|
|
149
|
+
const element = ref.current;
|
|
150
|
+
expect(element).not.toBeFalsy();
|
|
151
|
+
|
|
152
|
+
// Re-render with a label
|
|
153
|
+
result.rerender(
|
|
154
|
+
<Tooltip label="Some tooltip">
|
|
155
|
+
<span ref={ref}>some updated text</span>
|
|
156
|
+
</Tooltip>,
|
|
157
|
+
);
|
|
158
|
+
// Children ref is stable
|
|
159
|
+
expect(ref.current === element).toBe(true);
|
|
160
|
+
});
|
|
139
161
|
});
|
|
140
162
|
|
|
141
163
|
describe('activation', () => {
|
|
@@ -68,7 +68,7 @@ export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, re
|
|
|
68
68
|
const { label, children, className, delay, placement, forceOpen, ...forwardedProps } = props;
|
|
69
69
|
// Disable in SSR or without a label.
|
|
70
70
|
if (!DOCUMENT || !label) {
|
|
71
|
-
return
|
|
71
|
+
return <TooltipContextProvider>{children}</TooltipContextProvider>;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const id = useMemo(() => `tooltip-${uid()}`, []);
|