-
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
Conversation
@allroundexperts Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-07-18.at.2.16.27.PM.movMobile Web - ChromeScreen.Recording.2023-07-18.at.2.28.34.PM.movMobile Web - SafariScreen.Recording.2023-07-18.at.2.23.04.PM.movDesktopScreen.Recording.2023-07-18.at.2.19.48.PM.moviOSScreen.Recording.2023-07-18.at.2.25.15.PM.movAndroidScreen.Recording.2023-07-18.at.2.33.44.PM.mov |
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 show, the current edit message will be lost 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be ||
instead?
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.
if we go with || it should be !(isFocusedRef.current || EmojiPickerAction.isActiveReportAction(..))
then. So my intention here is would like to cover a case in small screen device, when we edit a message, then open Emoji, the edit composer will be lost focus => With current implement, when we hide the EmojiPicker, the main composer won't be show in small screen devices.
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.
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 comment
The 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:
- Login with userA’s account
- Create a public room with userA workspace
- Copy public room URL
- Open other browser and login with userB’s account
- Join the room by pasting room URL
- Send a message in room from userB
- Click on “Edit comment” message after sent
- Open emoji picker
- Switch back to UserA's account and delete the message sent by UserB
We can observe that EmojiPicker is hided but the main composer is hide as well.
Screen.Recording.2023-07-18.at.20.42.56.mov
So previously in the componentWillUnmount logic of ReportActionItemMessageEdit:
App/src/pages/home/report/ReportActionItemMessageEdit.js
Lines 120 to 129 in 38bc5b3
return () => { | |
// Skip if this is not the focused message so the other edit composer stays focused | |
if (!isFocusedRef.current) { | |
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); | |
}; |
We will check
- If we're focusing on a Edit message => When it's unmounted due to deleted
- If we're out focus on a Edit message => We're already show the main composer => Not need to show main composer anymore.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -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. |
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?
// Skip if this is not the focused message so the other edit composer stays focused. | |
// Skip showing the main composer if the context menu is active for this reportAction. We want the "Edit composer" text input stay focused in this case. |
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)
Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.3.44-0 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.44-2 🚀
|
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.3.45-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.45-7 🚀
|
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 comment
The 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 EmojiPickerAction.isActiveReportAction
check as it returns true for message A even though the emoji picker is no longer open.
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 EmojiPickerAction.isActiveReportAction
should return false.
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 comment
The 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
Details
Fixed Issues
$ #22214
PROPOSAL: #22214 (comment)
Tests
Offline tests
Could not test when network is offline
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screen.Recording.2023-07-17.at.20.39.07.-.web.mov
Mobile Web - Chrome
Screen.Recording.2023-07-17.at.20.54.58.-.android.chrome.mov
Mobile Web - Safari
Screen.Recording.2023-07-17.at.20.53.05.-.ios.safari.mov
Desktop
Screen.Recording.2023-07-17.at.20.45.05.-.desktop.mp4
iOS
Screen.Recording.2023-07-17.at.20.49.58.-.ios.mp4
Android
Screen.Recording.2023-07-17.at.20.53.58.-.android.mov