-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix the emoji picker does not close when editing message is deleted #22984
Changes from all commits
8e54486
376aa82
e0f14cd
08f8abf
2906498
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -34,6 +34,7 @@ import useLocalize from '../../../hooks/useLocalize'; | |||||||||||||||||||||
import useKeyboardState from '../../../hooks/useKeyboardState'; | ||||||||||||||||||||||
import useWindowDimensions from '../../../hooks/useWindowDimensions'; | ||||||||||||||||||||||
import useReportScrollManager from '../../../hooks/useReportScrollManager'; | ||||||||||||||||||||||
import * as EmojiPickerAction from '../../../libs/actions/EmojiPickerAction'; | ||||||||||||||||||||||
|
||||||||||||||||||||||
const propTypes = { | ||||||||||||||||||||||
/** All the data of the action */ | ||||||||||||||||||||||
|
@@ -118,16 +119,17 @@ function ReportActionItemMessageEdit(props) { | |||||||||||||||||||||
}); | ||||||||||||||||||||||
|
||||||||||||||||||||||
return () => { | ||||||||||||||||||||||
// Skip if this is not the focused message so the other edit composer stays focused | ||||||||||||||||||||||
if (!isFocusedRef.current) { | ||||||||||||||||||||||
// Skip if this is not the focused message so the other edit composer stays focused. | ||||||||||||||||||||||
// In small screen devices, when EmojiPicker is shown, the current edit message will lose focus, we need to check this case as well. | ||||||||||||||||||||||
if (!isFocusedRef.current && !EmojiPickerAction.isActiveReportAction(props.action.reportActionID)) { | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we go with || it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'm not getting the logic. Can you please explain further more clearly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright. With our change according to my proposal, we reveal another bug that I think we should fix it in this PR. Step to reproduce: on small screen devices:
Screen.Recording.2023-07-18.at.20.42.56.movSo previously in the componentWillUnmount logic of ReportActionItemMessageEdit: App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 120 to 129 in 38bc5b3
We will check
But with our change, when an Edit message is out focus, it might be there is a EmojiPicker is opening. So when we unmount an Edit message, we should check if there is an EmojiPicker related to the current Edit message is opening, we should show the main composer as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation. This makes sense! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This caused a regression (case 3). If we focus on message A, open it's emoji picker and close it, then focus on message B and delete message A then the main composer will show up. This is due to the faulty What we had to do is to clear the active report action accordingly i.e. if we are deleting message A and it's emoji picker is not open then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This caused a bug where this condition returns false when composer is not focused but save button is pressed, since onFocus function is synchronous and takes some times to get focus. Thus causing edit input to be still open and main composer not to show: #32218 |
||||||||||||||||||||||
return; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
// Show the main composer when the focused message is deleted from another client | ||||||||||||||||||||||
// to prevent the main composer stays hidden until we swtich to another chat. | ||||||||||||||||||||||
ComposerActions.setShouldShowComposeInput(true); | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
}, []); | ||||||||||||||||||||||
}, [props.action.reportActionID]); | ||||||||||||||||||||||
|
||||||||||||||||||||||
/** | ||||||||||||||||||||||
* Save the draft of the comment. This debounced so that we're not ceaselessly saving your edit. Saving the draft | ||||||||||||||||||||||
|
@@ -346,6 +348,7 @@ function ReportActionItemMessageEdit(props) { | |||||||||||||||||||||
onModalHide={() => InteractionManager.runAfterInteractions(() => textInputRef.current.focus())} | ||||||||||||||||||||||
onEmojiSelected={addEmojiToTextBox} | ||||||||||||||||||||||
nativeID={emojiButtonID} | ||||||||||||||||||||||
reportAction={props.action} | ||||||||||||||||||||||
/> | ||||||||||||||||||||||
</View> | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sort of confused by this comment. Do we mean something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nope @marcaaron . I'm not really full understand the first comment as well. But I guess what they mean is if we have multiple Editing messages, and if the current edit message is not focus when unmount => we can skip show main composer to let another editing message still be focused.
Back to our case, I would like to say if the current edit message is not focus by opening its EmojiPicker, we should treat as it's still focus and show main composer (because we are still editing this message)