-
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 money request tabs animation #29231
Conversation
# Conflicts: # src/components/TabSelector/TabSelector.js
}); | ||
} | ||
return themeColors.border; | ||
}; | ||
|
||
function TabSelector({state, navigation, onTabPress, position}) { | ||
const {translate} = useLocalize(); | ||
const [, reRender] = useReducer((x) => !x, false); |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
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.
LGTM
setTimeout(() => { | ||
setAffectedAnimatedTabs(defaultAffectedAnimatedTabs); | ||
}, CONST.ANIMATED_TRANSITION); | ||
// 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.
Can you explain why we add this as we do here?
Line 202 in 0cbee22
// eslint-disable-next-line react-hooks/exhaustive-deps -- we just want to revalidate the form on update if the preferred locale changed on another device so that errors get translated |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are usually against using setTimeout, why do we need it here?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Can you leave a comment then explaining why?
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.
@pecanoro updated.
@pecanoro bump. |
const [affectedAnimatedTabs, setAffectedAnimatedTabs] = useState(defaultAffectedAnimatedTabs); | ||
|
||
React.useEffect(() => { | ||
setTimeout(() => { |
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.
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 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
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