-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: issue 23908 #27190
fix: issue 23908 #27190
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem right, why we are doing 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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReportActionContextMenu.showDeleteModal(props.reportID, props.action, false, deleteDraft, () => InteractionManager.runAfterInteractions(() => textInputRef.current.focus())); |
We set focus in cancel handler, but it seems that focusing doesn't work on ios safari.
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 issue already exists on staging and not a regression. Will you check again?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we do this on onBlur
?
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.
No. We should keep active report action until another draft gets focused. This wasn't already confirmed?
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.
@s-alves10 This is not resolved yet. Can we do this any other way?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new approach can cause a regression.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB. isActive does not need to accept a parameter, the report action id will always be 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.
Updated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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 |
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.
Updated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments seems outdated, please update accordingly
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.
Updated
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
Please add a comment for the disabled eslint rule
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.
Added
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to call them here. Removed
ComposerActions.setShouldShowComposeInput(true); | ||
setShouldShowComposeInputKeyboardAware(true); |
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.
NAB. Do we need to make this keyboard aware? Will this introduce any delay?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 fixed the bug of isActiveReportAction
. Now this works fine as expected
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
ok, thanks.
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. |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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
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