From 45d1f34a3074782fb68d322cb90dc21b46744426 Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 21 Aug 2020 14:14:28 +0200 Subject: [PATCH] [Glitch] Fix scrolling issues when closing some dropdown menus Port c7cfd4e67aedb38cba3ee452e18bd086e30e2e5d to glitch-soc Signed-off-by: Thibaut Girka --- app/javascript/flavours/glitch/components/dropdown_menu.js | 2 +- .../flavours/glitch/features/compose/components/dropdown.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/javascript/flavours/glitch/components/dropdown_menu.js b/app/javascript/flavours/glitch/components/dropdown_menu.js index 60ed859a3f..e627ea51fd 100644 --- a/app/javascript/flavours/glitch/components/dropdown_menu.js +++ b/app/javascript/flavours/glitch/components/dropdown_menu.js @@ -205,7 +205,7 @@ export default class Dropdown extends React.PureComponent { handleClose = () => { if (this.activeElement) { - this.activeElement.focus(); + this.activeElement.focus({ preventScroll: true }); this.activeElement = null; } this.props.onClose(this.state.id); diff --git a/app/javascript/flavours/glitch/features/compose/components/dropdown.js b/app/javascript/flavours/glitch/features/compose/components/dropdown.js index 60035b7057..04ef3964b2 100644 --- a/app/javascript/flavours/glitch/features/compose/components/dropdown.js +++ b/app/javascript/flavours/glitch/features/compose/components/dropdown.js @@ -57,7 +57,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent { } else { const { top } = target.getBoundingClientRect(); if (this.state.open && this.activeElement) { - this.activeElement.focus(); + this.activeElement.focus({ preventScroll: true }); } this.setState({ placement: top * 2 < innerHeight ? 'bottom' : 'top' }); this.setState({ open: !this.state.open, openedViaKeyboard: type !== 'click' }); @@ -100,7 +100,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent { handleClose = () => { if (this.state.open && this.activeElement) { - this.activeElement.focus(); + this.activeElement.focus({ preventScroll: true }); } this.setState({ open: false }); }