Skip to content

Android-Emoji is selected only on second tap #8221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/components/EmojiPicker/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {Dimensions} from 'react-native';
import {Dimensions, Keyboard} from 'react-native';
import _ from 'underscore';
import EmojiPickerMenu from './EmojiPickerMenu';
import CONST from '../../CONST';
Expand Down Expand Up @@ -33,6 +33,15 @@ class EmojiPicker extends React.Component {
this.emojiPopoverDimensionListener = Dimensions.addEventListener('change', this.measureEmojiPopoverAnchorPosition);
}

componentDidUpdate(prevProps, prevState) {
if (prevState.isEmojiPickerVisible === this.state.isEmojiPickerVisible || !this.state.isEmojiPickerVisible) {
return;
}

// Dismiss the Keyboard and focus to prevent emoji press twice when selecting an emoji
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment could be better,

// Dismiss the keyboard to provide a focus for the emoji picker to avoid selection issues.
// Eg: https://github.com/Expensify/App/issues/8110

cc: @tgolen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't like this change. If we had a policy of a code comment referencing the GH for each issue that was fixed in the code, then the code will be littered with thousands of them. It's easy to find the associated GH for a change using "blame" to find the PR that introduced the code.

Can you please remove the GH link from the comment?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comment, @tgolen. I'm not sure, that's why I put up a cc: for you on this.

@mollfpr Sorry for the back and forth, remove the link & let us know.

Keyboard.dismiss();
}

componentWillUnmount() {
if (!this.emojiPopoverDimensionListener) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ class ReportActionCompose extends React.Component {
// Keyboard is not opened after Emoji Picker is closed
// SetTimeout is used as a workaround
// https://github.com/react-native-modal/react-native-modal/issues/114
// We carefully choose a delay. 50ms is found enough for keyboard to open.
setTimeout(() => this.textInput.focus(), 50);
// We carefully choose a delay. 100ms is found enough for keyboard to open.
setTimeout(() => this.textInput.focus(), 100);
}
});
}
Expand Down