Conversation
|
|
||
| if (isFocusedRef.current || EmojiPickerAction.isActive(props.action.reportActionID) || ReportActionContextMenu.isActiveReportAction(props.action.reportActionID)) { | ||
| setShouldShowComposeInputKeyboardAware(true); | ||
| isFocusedRef.current = true; |
There was a problem hiding this comment.
This does not seem right, why we are doing this?
There was a problem hiding this comment.
We have discussed the new issue of re-focusing for a brief moment here. This issue is introduced when I add onMouseDown={e => e.preventDefault()} props to the save button for prevent loosing focus.
deleteDraft method is called right before unmount is called. Setting this value ensures that the current action is active. We can fix the above issue(both Enter key or Save button) by this change
There was a problem hiding this comment.
I removed the above code. In order to prevent auto refocusing of composer input after delete modal is closed, I blurred the input element before showing the confirm modal
Please check the latest code
There was a problem hiding this comment.
We want to prevent refocusing on that input if we press Delete on the delete modal right? But what if we press Close on the modal? Will the input get refocused again? (check on both web and native)
There was a problem hiding this comment.
We set focus in cancel handler, but it seems that focusing doesn't work on ios safari.
There was a problem hiding this comment.
This issue already exists on staging and not a regression. Will you check again?
There was a problem hiding this comment.
Yeah not something that we should be concerned with here. Safari limit the focus functionality.
| // Clear active report action when another action gets focused | ||
| if (!EmojiPickerAction.isActive(props.action.reportActionID)) { | ||
| EmojiPickerAction.clearActive(); | ||
| } | ||
| if (!ReportActionContextMenu.isActiveReportAction(props.action.reportActionID)) { | ||
| ReportActionContextMenu.clearActiveReportAction(); | ||
| } |
There was a problem hiding this comment.
No. We should keep active report action until another draft gets focused. This wasn't already confirmed?
There was a problem hiding this comment.
@s-alves10 This is not resolved yet. Can we do this any other way?
There was a problem hiding this comment.
Clear active report action when another action gets focused
We shouldn't clear active action on blur because blurred action can be active.
I think we confirmed this in the proposal
Note: I guess we can clear active in onModalHide of EmojiPickerButton for EmojiPicker, and in confirm/cancel callback of showDeleteModal for ReportActionContextMenu. Please let me know your thoughts
There was a problem hiding this comment.
I think the new approach can cause a regression.
There was a problem hiding this comment.
I see. I don't think this is a blocker for now. Will need to test though
| // - it is focused or | ||
| // - EmojiPicker's activeID is equal to this action's reportActionID or | ||
| // - ReportActionContextMenu's reportActionID is equal to this action's reportActionID | ||
| const isActive = useCallback((reportActionID) => isFocusedRef.current || EmojiPickerAction.isActive(reportActionID) || ReportActionContextMenu.isActiveReportAction(reportActionID), []); |
There was a problem hiding this comment.
NAB. isActive does not need to accept a parameter, the report action id will always be props.action.reportActionID
| // We consider the report action in edit mode is active when | ||
| // - it is focused or | ||
| // - EmojiPicker's activeID is equal to this action's reportActionID or | ||
| // - ReportActionContextMenu's reportActionID is equal to this action's reportActionID |
There was a problem hiding this comment.
| // We consider the report action in edit mode is active when | |
| // - it is focused or | |
| // - EmojiPicker's activeID is equal to this action's reportActionID or | |
| // - ReportActionContextMenu's reportActionID is equal to this action's reportActionID | |
| // We consider the report action active if it's focused, its emoji picker is open or its context menu is open |
| // 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.isActive(props.action.reportActionID)) { | ||
| // When delete modal is opened, the current edit message will lose focus, we need to check this case as well |
There was a problem hiding this comment.
The comments seems outdated, please update accordingly
| ComposerActions.setShouldShowComposeInput(true); | ||
| setShouldShowComposeInputKeyboardAware(true); | ||
| }; | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Please add a comment for the disabled eslint rule
| setShouldShowComposeInputKeyboardAware(true); | ||
| ReportActionComposeFocusManager.clear(); | ||
| ReportActionComposeFocusManager.focus(); | ||
| if (EmojiPickerAction.isActive(props.action.reportActionID)) { | ||
| EmojiPickerAction.clearActive(); | ||
| } | ||
| if (ReportActionContextMenu.isActiveReportAction(props.action.reportActionID)) { | ||
| ReportActionContextMenu.clearActiveReportAction(); | ||
| } |
There was a problem hiding this comment.
Do we need to call setShouldShowComposeInputKeyboardAware, EmojiPickerAction.clearActive and ReportActionContextMenu.clearActiveReportAction here? Won't they get called on the unmount phase?
There was a problem hiding this comment.
I think we don't need to call them here. Removed
| ComposerActions.setShouldShowComposeInput(true); | ||
| setShouldShowComposeInputKeyboardAware(true); |
There was a problem hiding this comment.
NAB. Do we need to make this keyboard aware? Will this introduce any delay?
There was a problem hiding this comment.
I don't think so. I think showing composer after keyboard is closed is good. If keyboard isn't visible, this would show composer immediately
|
Please take a look again |
|
In step 21
Please change to: |
| ReportActionComposeFocusManager.focus(); | ||
|
|
||
| if (isActive()) { | ||
| ReportActionComposeFocusManager.clear(); | ||
| ReportActionComposeFocusManager.focus(); | ||
| } |
There was a problem hiding this comment.
I think this may be causing a regression. Can we remove the condition here? Currently if we delete a message the focus is not set back to the main composer but it should
There was a problem hiding this comment.
I think that solution won't work. We still need to find a way to fix the regression though
There was a problem hiding this comment.
I think we should focus the main composer if the deleted message is active. Please let me know if I am wrong
There was a problem hiding this comment.
That's correct but apparently this is not the behavior
Screen.Recording.2023-09-14.at.5.29.25.PM.mov
There was a problem hiding this comment.
I fixed the bug of isActiveReportAction. Now this works fine as expected
There was a problem hiding this comment.
I guess this is resolved, right? Because I too agree the expected behaviour is that composer should get the focus.
There was a problem hiding this comment.
|
Can you specify that the tests are for mobile only as the main composer will only get hidden in mobile |
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemweb-chrome.movMobile Web - Safarimweb-safari.movDesktopdesktop.moviOSios.movAndroidandroid.mov |
Please check the chat history #27190 (comment) |
I think these tests are for small screen devices |
|
I updated the test steps accordingly. Will you check again? |
|
Please check #27190 (comment) |
|
Please take a look |
|
Taking a look. |
techievivek
left a comment
There was a problem hiding this comment.
Great work on this one. 🙇 @s77rt @s-alves10
|
✋ 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/techievivek in version: 1.3.71-0 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.71-12 🚀
|
| // When active action changes, we need to update the `isContextMenuActive` state | ||
| const isActiveReportActionForMenu = ReportActionContextMenu.isActiveReportAction(props.action.reportActionID); | ||
| useEffect(() => { | ||
| setIsContextMenuActive(isActiveReportActionForMenu); | ||
| }, [isActiveReportActionForMenu]); |
There was a problem hiding this comment.
As this effect depends on temporary data it is not synced with the lifecycle of other components creating inconsistencies between states of components. It caused #28029
Details
Show the main composer only when there is no focused message in edit mode
Fixed Issues
$ #23908
PROPOSAL: #23908 (comment)
Tests
Note: These tests are for small screen devices. Step 5 - 6 are for mobile platforms.
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
23908_mac_chrome.mp4
Mobile Web - Chrome
23908_android_chrome.mp4
Mobile Web - Safari
23908_ios_safari.mp4
Desktop
23908_mac_desktop.mp4
iOS
23908_ios_native.mp4
Android
23908_android_native.mp4