Visibility modal: Match dropdown width to button (#36054)

This commit is contained in:
diondiondion 2025-09-08 14:43:38 +02:00 committed by GitHub
commit 0153b49ef7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 2 deletions

View file

@ -0,0 +1,17 @@
import type { Modifier, UsePopperState } from 'react-overlays/esm/usePopper';
export const matchWidth: Modifier<'sameWidth', UsePopperState> = {
name: 'sameWidth',
enabled: true,
phase: 'beforeWrite',
requires: ['computeStyles'],
fn: ({ state }) => {
if (state.styles.popper) {
state.styles.popper.width = `${state.rects.reference.width}px`;
}
},
effect: ({ state }) => {
const reference = state.elements.reference as HTMLElement;
state.elements.popper.style.width = `${reference.offsetWidth}px`;
},
};