mirror of
https://github.com/mastodon/mastodon.git
synced 2025-10-06 00:52:42 +00:00
18 lines
542 B
TypeScript
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`;
|
|
},
|
|
};
|