-
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 can't open emoji picker when edit composer is focused #54858
Fix can't open emoji picker when edit composer is focused #54858
Conversation
@DylanDylann 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] |
if ( | ||
relatedTargetId === CONST.COMPOSER.NATIVE_ID || | ||
relatedTargetId === CONST.EMOJI_PICKER_BUTTON_NATIVE_ID || | ||
EmojiPickerAction.isActive(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.
@bernhardoj Could you please explain this change? Is there any difference here? Thanks
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.
EmojiPickerAction.isEmojiPickerVisible() checks if a emoji picker is visible. EmojiPickerAction.isActive(action.reportActionID) checks if the emoji picker with an ID of action.reportActionID is visible. This way, we only prevent showing the main composer if the emoji picker is shown from the edit composer picker.
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.
@bernhardoj We have an inconsistency between IOS and Android that is caused by this change.
Android and safari | IOS and mWeb in Android |
---|---|
Screen.Recording.2025-01-13.at.16.33.04.mov |
400670619-eea2a373-6b79-4a38-b67b-c584cf1668b5.mp4 |
From my viewpoint, both behavior looks fine but we need to make it consistent (at least consistency on native and consistency on mWeb)
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.
Can you explain the inconsistency? The steps performed on the 1st video (android only) is different from the 2nd video (iOS only)
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.
Ahh sorry, I made a wrong video
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, I see. From the video, you can see the chat behind the context menu is moving up which indicates the edit composer is blurred when showing the emoji picker and the main composer shows, but then it moves down again because the edit composer is somehow refocused.
I've tried commenting these codes
App/src/pages/home/report/ReportActionItemMessageEdit.tsx
Lines 194 to 203 in 3cf6037
const focus = useCallback((shouldDelay = false, forcedSelectionRange?: Selection) => { | |
focusComposerWithDelay(textInputRef.current)(shouldDelay, forcedSelectionRange); | |
}, []); | |
// Take over focus priority | |
const setUpComposeFocusManager = useCallback(() => { | |
ReportActionComposeFocusManager.onComposerFocus(() => { | |
focus(true, emojiPickerSelectionRef.current ? {...emojiPickerSelectionRef.current} : undefined); | |
}, true); | |
}, [focus]); |
even commenting the ref
App/src/pages/home/report/ReportActionItemMessageEdit.tsx
Lines 509 to 517 in 3cf6037
ref={(el: TextInput & HTMLTextAreaElement) => { | |
textInputRef.current = el; | |
if (typeof forwardedRef === 'function') { | |
forwardedRef(el); | |
} else if (forwardedRef) { | |
// eslint-disable-next-line no-param-reassign | |
forwardedRef.current = el; | |
} | |
}} |
but the refocus still happens.
The composer is blurred when the emoji picker is shown because of this code.
App/src/components/Modal/BaseModal.tsx
Lines 75 to 78 in 3cf6037
const saveFocusState = useCallback(() => { | |
if (shouldEnableNewFocusManagement) { | |
ComposerFocusManager.saveFocusState(uniqueModalId); | |
} |
saveFocusState
blurs the current active input. I have commenting refocusAfterModalFullyClosed
too, but still happens. I think it's a RN bug.
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.
@bernhardoj How about your second approach?
Second, we can refocus to the edit composer when the emoji picker from context menu hides, only if it's a small screen.
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.
For that approach, I was thinking that maybe we can use ReportActionComposeFocusManager.focus()
and call it here.
setIsEmojiPickerActive as () => void, |
(isActive) => {
setIsEmojiPickerActive(isActive);
if (!isActive) ReportActionComposeFocusManager.focus()
}
But I think that's like a workaround to hide the real issue. I think it's better to report it as a new issue and find someone to investigate why it happens like that on Android.
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.
@bernhardoj This is an additional bug and it is out of the scope of the original issue. And your solution can't solve this bug completely. So I suggest we should revert this change here and create a new issue to address this additional bug. If you agree, please test again on platforms after reverting
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.
Done
I can't reproduce this problem after applying the fix for the original bug |
Did you test it on web or native? It should happen on native without the EmojiPickerAction.isActive(action.reportActionID) update |
Ahh I see it |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-01-17.at.15.51.33.movAndroid: mWeb ChromeScreen.Recording.2025-01-17.at.15.07.38.moviOS: NativeScreen.Recording.2025-01-17.at.15.54.16.moviOS: mWeb SafariScreen.Recording.2025-01-17.at.15.07.01.movMacOS: Chrome / SafariScreen.Recording.2025-01-17.at.15.06.21.movMacOS: DesktopScreen.Recording.2025-01-17.at.15.08.13.mov |
✋ 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: 9.0.87-0 🚀
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.0.87-3 🚀
|
Explanation of Change
Fixed Issues
$ #54599
PROPOSAL: #54599 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.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
Android: Native
android.mp4
Android: mWeb Chrome
android.mweb.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4