[Glitch] Fix scrolling issues when closing some dropdown menus

Port c7cfd4e67a to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
master
ThibG 4 years ago committed by Thibaut Girka
parent 8c3c27bf06
commit 45d1f34a30
  1. 2
      app/javascript/flavours/glitch/components/dropdown_menu.js
  2. 4
      app/javascript/flavours/glitch/features/compose/components/dropdown.js

@ -205,7 +205,7 @@ export default class Dropdown extends React.PureComponent {
handleClose = () => { handleClose = () => {
if (this.activeElement) { if (this.activeElement) {
this.activeElement.focus(); this.activeElement.focus({ preventScroll: true });
this.activeElement = null; this.activeElement = null;
} }
this.props.onClose(this.state.id); this.props.onClose(this.state.id);

@ -57,7 +57,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent {
} else { } else {
const { top } = target.getBoundingClientRect(); const { top } = target.getBoundingClientRect();
if (this.state.open && this.activeElement) { if (this.state.open && this.activeElement) {
this.activeElement.focus(); this.activeElement.focus({ preventScroll: true });
} }
this.setState({ placement: top * 2 < innerHeight ? 'bottom' : 'top' }); this.setState({ placement: top * 2 < innerHeight ? 'bottom' : 'top' });
this.setState({ open: !this.state.open, openedViaKeyboard: type !== 'click' }); this.setState({ open: !this.state.open, openedViaKeyboard: type !== 'click' });
@ -100,7 +100,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent {
handleClose = () => { handleClose = () => {
if (this.state.open && this.activeElement) { if (this.state.open && this.activeElement) {
this.activeElement.focus(); this.activeElement.focus({ preventScroll: true });
} }
this.setState({ open: false }); this.setState({ open: false });
} }

Loading…
Cancel
Save