]> cat aescling's git repositories - mastodon.git/commitdiff
Fix page incorrectly scrolling when bringing up dropdown menus (#13574)
authorThibG <thib@sitedethib.com>
Tue, 28 Apr 2020 11:19:39 +0000 (13:19 +0200)
committerGitHub <noreply@github.com>
Tue, 28 Apr 2020 11:19:39 +0000 (13:19 +0200)
Fixes #13573

For some reason (I suspect this may be related to focusing the item before it
got drown by the browser), Firefox scrolls to top when bringing up dropdown
menus with pre-selected items.

This commit uses the “preventScroll” option as, due to the placement behavior,
the menu should be visible anyway and not trigger scrolling.

app/javascript/mastodon/components/dropdown_menu.js
app/javascript/mastodon/features/compose/components/privacy_dropdown.js

index 31c02d735c8373271f7517846796c1ab5ef9b7d5..4734e0f3fc4a6c09729984e3bd0af272ce58c527 100644 (file)
@@ -46,7 +46,7 @@ class DropdownMenu extends React.PureComponent {
     document.addEventListener('keydown', this.handleKeyDown, false);
     document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
     if (this.focusedItem && this.props.openedViaKeyboard) {
-      this.focusedItem.focus();
+      this.focusedItem.focus({ preventScroll: true });
     }
     this.setState({ mounted: true });
   }
index 57588fe960ddaf99fc7ad12733d18cec39bf98cc..96028e0421f164fbf399babe2bdcd7daa195d610 100644 (file)
@@ -100,7 +100,7 @@ class PrivacyDropdownMenu extends React.PureComponent {
   componentDidMount () {
     document.addEventListener('click', this.handleDocumentClick, false);
     document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
-    if (this.focusedItem) this.focusedItem.focus();
+    if (this.focusedItem) this.focusedItem.focus({ preventScroll: true });
     this.setState({ mounted: true });
   }