You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
542 B
17 lines
542 B
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`; |
|
}, |
|
};
|
|
|