-
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: scroll date of birth year list on first mount only #23079
Conversation
@fedirjh FYI, I'm not using |
if (!firstLayoutRef.current) { | ||
return; | ||
} |
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.
@allroundexperts Let's move the logic inside scrollToIndex
method.
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.
Hm... Are you sure about this? I mean it would be better if the scrollToIndex
function would have single responsibility.
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.
Oh I thought it was used only for this instance , it seems to be used on ArrowKeyFocusManager
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.
I wonder why we can’t just remove the scrolling onLayout
? it does feel like a workaround.
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.
Well, removing it would not scroll the list to the last element.
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’t we fix that with a useEffect
? something like
useEffect(() => scrollToIndex(focusedIndex, false), [focusedIndex]);
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 is what I tried first. It works on every platform except on iOS 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.
Another option would have been to have a state + useEffect:
const [onLayoutTriggered, setOnLayoutTriggered] = useState(false);
useEffect(() => {
if (onLayoutTriggered) {
scrollToIndex(focusedIndex, false);
}
}, [focusedIndex, onLayoutTriggered]);
...
<SectionList
onLayout={() => setOnLayoutTriggered(true)}
</SectionList>
but I'm not really sure that that is better than what you did with the ref.
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.
Hm... Are you sure about this? I mean it would be better if the scrollToIndex function would have single responsibility.
Agree, I prefer how it is now.
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 I'm not really sure that that is better than what you did with the ref.
I think ref is better approach as it doesn’t trigger a re-render when it's updated unlike using the state.
Reviewer Checklist
Screenshots/VideosWebWeb.mp4Mobile Web - ChromeChrome.mp4Mobile Web - SafariSafari.mp4DesktopDesktop.mp4iOSIOS.mp4AndroidAndroid.mp4 |
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.
Looks good to me and tests well.
✋ 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/aldo-expensify in version: 1.3.44-0 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.44-2 🚀
|
🚀 Deployed to staging by https://github.com/aldo-expensify in version: 1.3.45-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.45-7 🚀
|
Details
This PR modifies the logic inside the SectionList, such that it scrolls to the focus index only on the first layout.
Fixed Issues
$ #22689
PROPOSAL: #22689 (comment)
Tests
Offline tests
N/A
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)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
Screen.Recording.2023-07-18.at.5.21.31.PM.mov
Mobile Web - Chrome
Screen.Recording.2023-07-18.at.5.24.41.PM.mov
Mobile Web - Safari
Screen.Recording.2023-07-18.at.5.23.42.PM.mov
Desktop
Screen.Recording.2023-07-18.at.5.22.27.PM.mov
iOS
Screen.Recording.2023-07-18.at.5.23.10.PM.mov
Android
Screen.Recording.2023-07-18.at.5.25.49.PM.mov