Fix width of dropdown menus

This commit is contained in:
Dane Everitt 2020-12-27 10:49:33 -08:00
parent b2328b50c6
commit d54a8713d1
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -40,9 +40,7 @@ class DropdownMenu extends React.PureComponent<Props, State> {
if (this.state.visible && !prevState.visible && menu) { if (this.state.visible && !prevState.visible && menu) {
document.addEventListener('click', this.windowListener); document.addEventListener('click', this.windowListener);
document.addEventListener('contextmenu', this.contextMenuListener); document.addEventListener('contextmenu', this.contextMenuListener);
menu.setAttribute( menu.style.left = `${Math.round(this.state.posX - menu.clientWidth)}px`;
'style', `left: ${Math.round(this.state.posX - menu.clientWidth)}px`,
);
} }
if (!this.state.visible && prevState.visible) { if (!this.state.visible && prevState.visible) {
@ -94,6 +92,7 @@ class DropdownMenu extends React.PureComponent<Props, State> {
e.stopPropagation(); e.stopPropagation();
this.setState({ visible: false }); this.setState({ visible: false });
}} }}
style={{ width: '12rem' }}
css={tw`absolute bg-white p-2 rounded border border-neutral-700 shadow-lg text-neutral-500 z-50`} css={tw`absolute bg-white p-2 rounded border border-neutral-700 shadow-lg text-neutral-500 z-50`}
> >
{this.props.children} {this.props.children}