Compare commits

...
Author SHA1 Message Date
Ken 56718b48c9 perf(Popover): Only calculate position when open 2026-10-30 13:06:35 +01:00
2 changed files with 11 additions and 2 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---
Popover: Closed popovers no longer calculate their position on mount. This makes pages with many Dropdowns or HelpTexts render faster.
@@ -123,9 +123,13 @@ const PopoverRoot = forwardRef<HTMLDivElement, PopoverProps>(
],
});
/**
* Only give Floating UI a reference while open. Otherwise every closed instance
* computes (and commits) a position
*/
useClientLayoutEffect(() => {
refs.setReference(anchorEl);
}, [anchorEl, refs]);
refs.setReference(open ? anchorEl : null);
}, [anchorEl, open, refs]);
const floatingRef = useMergeRefs(refs.setFloating, ref);