-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix wrong cursor after close emoji picker #62071
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 wrong cursor after close emoji picker #62071
Conversation
@mananjadhav 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] |
src/hooks/useSidePanel.ts
Outdated
@@ -64,7 +64,7 @@ function useSidePanel() { | |||
const {windowWidth} = useWindowDimensions(); | |||
const sidePanelWidth = shouldUseNarrowLayout ? windowWidth : variables.sideBarWidth; | |||
|
|||
const [isSidePanelTransitionEnded, setIsSidePanelTransitionEnded] = useState(false); | |||
const [isSidePanelTransitionEnded, setIsSidePanelTransitionEnded] = useState(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.
I changed this to true because the side panel is not transitioning at all initially. This is to fix an issue where the edit composer won't be refocused after closing the emoji picker because ready to focus promise is never resolved.
App/src/libs/ComposerFocusManager.ts
Lines 203 to 211 in 11385b8
function setReadyToFocus(id?: ModalId) { | |
const key = id ?? getTopmostModalId(); | |
const promise = promiseMap.get(key); | |
if (!promise) { | |
return; | |
} | |
promise.resolve?.(); | |
promiseMap.delete(key); | |
} |
The promise is created because the help modal is mounted even though it shouldn't be.
App/src/components/SidePanel/HelpModal/index.tsx
Lines 45 to 62 in 11385b8
useEffect(() => { | |
ComposerFocusManager.resetReadyToFocus(uniqueModalId); | |
window.history.pushState({isSidePanelOpen: true}, '', null); | |
const handlePopState = () => { | |
if (isExtraLargeScreenWidth) { | |
return; | |
} | |
closeSidePanel(); | |
}; | |
window.addEventListener('popstate', handlePopState); | |
return () => { | |
window.removeEventListener('popstate', handlePopState); | |
ComposerFocusManager.setReadyToFocus(uniqueModalId); | |
}; | |
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | |
}, []); |
App/src/components/SidePanel/index.tsx
Lines 5 to 15 in 11385b8
function SidePanel() { | |
const {isSidePanelTransitionEnded, shouldHideSidePanel, sidePanelTranslateX, shouldHideSidePanelBackdrop, closeSidePanel} = useSidePanel(); | |
if (isSidePanelTransitionEnded && shouldHideSidePanel) { | |
return null; | |
} | |
return ( | |
<Help | |
shouldHideSidePanel={shouldHideSidePanel} | |
sidePanelTranslateX={sidePanelTranslateX} |
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.
But mWeb still doesn't refocus because of the early return here:
App/src/pages/home/report/ReportActionItemMessageEdit.tsx
Lines 525 to 531 in 11385b8
onModalHide={() => { | |
const activeElementId = DomUtils.getActiveElement()?.id; | |
if (activeElementId === CONST.COMPOSER.NATIVE_ID || activeElementId === CONST.EMOJI_PICKER_BUTTON_NATIVE_ID) { | |
return; | |
} | |
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.
Is this an existing bug or a result of our change. Have we tested if it is causing any 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.
It's actually a bug from #61884. Before the early return added here, setIsSidePanelTransitionEnded(true)
will be called after it's mounted and the animation is done (even though technically there is nothing to animate), so the value will eventually be true too.
Lines 76 to 96 in d4347a6
useEffect(() => { | |
if (shouldHideSidePanel && prevShouldHideSidePanel) { | |
sidePanelTranslateX.current.setValue(sidePanelWidth); | |
sidePanelOffset.current.setValue(shouldApplySidePanelOffset ? variables.sideBarWidth : 0); | |
return; | |
} | |
setIsSidePanelTransitionEnded(false); | |
Animated.parallel([ | |
Animated.timing(sidePanelOffset.current, { | |
toValue: shouldApplySidePanelOffset ? variables.sideBarWidth : 0, | |
duration: CONST.ANIMATED_TRANSITION, | |
useNativeDriver: true, | |
}), | |
Animated.timing(sidePanelTranslateX.current, { | |
toValue: shouldHideSidePanel ? sidePanelWidth : 0, | |
duration: CONST.ANIMATED_TRANSITION, | |
useNativeDriver: true, | |
}), | |
]).start(() => setIsSidePanelTransitionEnded(true)); | |
}, [shouldHideSidePanel, shouldApplySidePanelOffset, sidePanelWidth, prevShouldHideSidePanel]); |
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 now have an issue created for that 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.
The offending PR is reverted, should I revert this back?
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.
Yes please.
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 check if syncing with main fixes it?
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.
Syncing with main and reverting this change fixes it.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid-emoji-cursor.movAndroid: mWeb Chromemweb-chrome-emoji-cursor.moviOS: HybridAppios-emoji-cursor.moviOS: mWeb Safarimweb-safari-emoji-cursor.movMacOS: Chrome / Safariweb-emoji-cursor.movMacOS: Desktopdesktop-emoji-cursor.mov |
@AndrewGable Quick bump. Failing tests are unrelated. Possible to rerun and check? |
✋ 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/AndrewGable in version: 9.1.51-0 🚀
|
Explanation of Change
Fixed Issues
$ #61292
PROPOSAL: #61292 (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
sectioncanBeMissing
param foruseOnyx
toggleReport
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
iOS: Native
ios.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4