mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 00:38:27 +00:00
[Glitch] Visibility modal: Match dropdown width to button
Port 0153b49ef7 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
17
app/javascript/flavours/glitch/components/dropdown/utils.ts
Normal file
17
app/javascript/flavours/glitch/components/dropdown/utils.ts
Normal 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`;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user