mirror of https://github.com/mastodon/mastodon
Visibility modal: Match dropdown width to button (#36054)
parent
24fb862a65
commit
0153b49ef7
@ -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`;
|
||||
},
|
||||
};
|
||||
Loading…
Reference in New Issue