diondiondion 435f536375 [Glitch] Visibility modal: Match dropdown width to button
Port 0153b49ef73b800b3a1b026c08aacb249d760244 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2025-09-10 18:34:30 +02:00

18 lines
542 B
TypeScript

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`;
},
};