Browse Source

Fix page incorrectly scrolling when bringing up dropdown menus (#13574)

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.
master
ThibG 4 years ago
committed by GitHub
parent
commit
77ec0875ea
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions
  1. +1
    -1
      app/javascript/mastodon/components/dropdown_menu.js
  2. +1
    -1
      app/javascript/mastodon/features/compose/components/privacy_dropdown.js

+ 1
- 1
app/javascript/mastodon/components/dropdown_menu.js View 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 });
}

+ 1
- 1
app/javascript/mastodon/features/compose/components/privacy_dropdown.js View 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 });
}

Loading…
Cancel
Save