fix money request tabs animation#29231
Conversation
# Conflicts: # src/components/TabSelector/TabSelector.js
|
|
||
| function TabSelector({state, navigation, onTabPress, position}) { | ||
| const {translate} = useLocalize(); | ||
| const [, reRender] = useReducer((x) => !x, false); |
There was a problem hiding this comment.
This looks kinda hack-ish. Wouldn't it be better to just keep affectedAnimatedTabs in state like below?
const defaultAffectedAnimatedTabs = Array.from({length: state.routes.length}, (v, i) => i);
const [affectedAnimatedTabs, setAffectedAnimatedTabs] = React.useState(defaultAffectedAnimatedTabs);
React.useEffect(() => {
setTimeout(() => {
setAffectedAnimatedTabs(defaultAffectedAnimatedTabs);
}, CONST.ANIMATED_TRANSITION);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state.index]);
There was a problem hiding this comment.
@burczu
Yes, I think this is better.
Updated!
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-10-13.at.11.49.58.movMobile Web - ChromeScreen.Recording.2023-10-13.at.11.55.52.movMobile Web - SafariScreen.Recording.2023-10-13.at.11.54.53.movDesktopScreen.Recording.2023-10-13.at.11.57.56.moviOSScreen.Recording.2023-10-13.at.11.53.55.movAndroidScreen.Recording.2023-10-13.at.11.52.52.mov |
| setTimeout(() => { | ||
| setAffectedAnimatedTabs(defaultAffectedAnimatedTabs); | ||
| }, CONST.ANIMATED_TRANSITION); | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Can you explain why we add this as we do here?
Line 202 in 0cbee22
There was a problem hiding this comment.
I add eslint-disable because putting defaultAffectedAnimatedTabs as deps will reset the affectedAnimatedTabs in every render, because const defaultAffectedAnimatedTabs will re-define the const in every render and is considered deps change because reference identity is changed.
I think we can remove eslint-disable and use useMemo
const defaultAffectedAnimatedTabs = useMemo(() => Array.from({length: state.routes.length}, (v, i) => i), [state.routes.length]);
React.useEffect(() => {
setTimeout(() => {
setAffectedAnimatedTabs(defaultAffectedAnimatedTabs);
}, CONST.ANIMATED_TRANSITION);
}, [defaultAffectedAnimatedTabs, state.index]);| const [affectedAnimatedTabs, setAffectedAnimatedTabs] = useState(defaultAffectedAnimatedTabs); | ||
|
|
||
| React.useEffect(() => { | ||
| setTimeout(() => { |
There was a problem hiding this comment.
We are usually against using setTimeout, why do we need it here?
There was a problem hiding this comment.
We need here to reset affectedAnimatedTabs after transition end, and I think this is the available way to wait transition end.
Removing setTimeout will back the issue to happened again because while moving from tab1 to tabs3 the transition is not end yet and at this time calling reset affectedAnimatedTabs to default will reset it to [tab1, tab2, tab3] while we need it to keep it [tab1, tab3] until transition end
There was a problem hiding this comment.
Got it! Can you leave a comment then explaining why?
|
@pecanoro bump. |
| const [affectedAnimatedTabs, setAffectedAnimatedTabs] = useState(defaultAffectedAnimatedTabs); | ||
|
|
||
| React.useEffect(() => { | ||
| setTimeout(() => { |
There was a problem hiding this comment.
Got it! Can you leave a comment then explaining why?
|
✋ 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/pecanoro in version: 1.3.87-0 🚀
|
1 similar comment
|
🚀 Deployed to staging by https://github.com/pecanoro in version: 1.3.87-0 🚀
|
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.87-12 🚀
|
|
🚀 Deployed to staging by https://github.com/pecanoro in version: 1.3.88-0 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.88-11 🚀
|
Details
Fixed Issues
$ #27563
PROPOSAL: #27563 (comment)
Tests
Offline tests
N/A.
QA Steps
Same as Tests step.
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
Android: Native
20231010212057172.mp4
Android: mWeb Chrome
20231010205138127.mp4
iOS: Native
20231010203650021.mp4
iOS: mWeb Safari
20231010203959460.mp4
MacOS: Chrome / Safari
20231010201946046.mp4
MacOS: Desktop
20231010203035492.mp4