Browse Source

Fix opening the emoji picker scrolling the single-column view to the top (#17579)

Fixes #17577
closed-social-glitch-2
Claire 2 years ago
committed by GitHub
parent
commit
aa86cf9557
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js

+ 13
- 2
app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js View File

@ -170,7 +170,7 @@ class EmojiPickerMenu extends React.PureComponent {
state = {
modifierOpen: false,
placement: null,
readyToFocus: false,
};
handleDocumentClick = e => {
@ -182,6 +182,16 @@ class EmojiPickerMenu extends React.PureComponent {
componentDidMount () {
document.addEventListener('click', this.handleDocumentClick, false);
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
// Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need
// to wait for a frame before focusing
requestAnimationFrame(() => {
this.setState({ readyToFocus: true });
if (this.node) {
const element = this.node.querySelector('input[type="search"]');
if (element) element.focus();
}
});
}
componentWillUnmount () {
@ -281,7 +291,7 @@ class EmojiPickerMenu extends React.PureComponent {
showSkinTones={false}
backgroundImageFn={backgroundImageFn}
notFound={notFoundFn}
autoFocus
autoFocus={this.state.readyToFocus}
emojiTooltip
/>
@ -314,6 +324,7 @@ class EmojiPickerDropdown extends React.PureComponent {
state = {
active: false,
loading: false,
placement: null,
};
setRef = (c) => {

Loading…
Cancel
Save