@lumx/react 3.11.3-alpha.0 → 3.11.3-alpha.2
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
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"url": "https://github.com/lumapps/design-system/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@lumx/core": "^3.11.3-alpha.
|
|
10
|
-
"@lumx/icons": "^3.11.3-alpha.
|
|
9
|
+
"@lumx/core": "^3.11.3-alpha.2",
|
|
10
|
+
"@lumx/icons": "^3.11.3-alpha.2",
|
|
11
11
|
"@popperjs/core": "^2.5.4",
|
|
12
12
|
"body-scroll-lock": "^3.1.5",
|
|
13
13
|
"classnames": "^2.3.2",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"build:storybook": "storybook build"
|
|
111
111
|
},
|
|
112
112
|
"sideEffects": false,
|
|
113
|
-
"version": "3.11.3-alpha.
|
|
113
|
+
"version": "3.11.3-alpha.2"
|
|
114
114
|
}
|
|
@@ -141,10 +141,18 @@ export function usePopoverStyle({
|
|
|
141
141
|
if (!update || !popperElement || !anchorElement || !WINDOW?.ResizeObserver) {
|
|
142
142
|
return undefined;
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
let running: ReturnType<typeof setTimeout> | undefined;
|
|
145
|
+
function updateRateLimited() {
|
|
146
|
+
if (running) return;
|
|
147
|
+
update?.();
|
|
148
|
+
running = setTimeout(() => {
|
|
149
|
+
running = undefined;
|
|
150
|
+
}, 100);
|
|
151
|
+
}
|
|
152
|
+
updateRateLimited();
|
|
145
153
|
|
|
146
154
|
// On anchor or popover resize
|
|
147
|
-
const resizeObserver = new ResizeObserver(
|
|
155
|
+
const resizeObserver = new ResizeObserver(updateRateLimited);
|
|
148
156
|
resizeObserver.observe(anchorElement);
|
|
149
157
|
resizeObserver.observe(popperElement);
|
|
150
158
|
return () => {
|
|
@@ -144,6 +144,8 @@ describe(`<${Tooltip.displayName}>`, () => {
|
|
|
144
144
|
});
|
|
145
145
|
expect(tooltip).toBeInTheDocument();
|
|
146
146
|
expect(tooltip).toHaveClass(VISUALLY_HIDDEN);
|
|
147
|
+
// Popper styles should not be applied when closed.
|
|
148
|
+
expect(tooltip?.style?.transform).toBe('');
|
|
147
149
|
|
|
148
150
|
const anchor = screen.getByRole('button', { name: 'Anchor' });
|
|
149
151
|
await userEvent.hover(anchor);
|
package/src/hooks/usePopper.ts
CHANGED
|
@@ -3,7 +3,10 @@ import { IS_BROWSER } from '@lumx/react/constants';
|
|
|
3
3
|
|
|
4
4
|
/** Stub usePopper for use outside of browsers */
|
|
5
5
|
const useStubPopper: typeof usePopperHook = (_a, _p, { placement }: any) =>
|
|
6
|
-
({
|
|
6
|
+
({
|
|
7
|
+
attributes: { popper: { 'data-popper-placement': placement } },
|
|
8
|
+
styles: { popper: { transform: 'translate(1, 1)' } },
|
|
9
|
+
}) as any;
|
|
7
10
|
|
|
8
11
|
/** Switch hook implementation between environment */
|
|
9
12
|
export const usePopper: typeof usePopperHook = IS_BROWSER ? usePopperHook : useStubPopper;
|