-
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
[HOLD for payment 2024-01-09] [$500] Theme - Skeleton placeholder in LHN does not switch theme when device theme is switched #33163
Comments
Triggered auto assignment to @sophiepintoraetz ( |
Job added to Upwork: https://www.upwork.com/jobs/~016c5e43f31286b1d7 |
Bug0 Triage Checklist (Main S/O)
|
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh ( |
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
|
Triggered auto assignment to @flodnv ( |
ProposalProblemSkeleton placeholder in LHN does not switch theme when device theme is switched Root Causewe do have any logic to rerender the skeleton when theme changes so the skeleton no rerender in Changessetup a componentdidUpdate to rerender the skeleton with correct theme when theme chages in componentDidUpdate(prevProps) {
if(prevProps.theme.skeletonLHNIn === this.props.theme.skeletonLHNIn) {
return
}
this.generateSkeletonViewItems(this.state.skeletonViewItems.length, true)
}
generateSkeletonViewItems(numItems, forceRerender=false) {
if (this.state.skeletonViewItems.length === numItems && !forceRerender)
return;
}
// rest of code
const startIndex = forceRerender ? 0 : this.state.skeletonViewItems.length;
for (let i = startIndex; i < numItems; i++) {
// rest of code
this.setState((prevState) => ({
skeletonViewItems: forceRerender ? skeletonViewItems : [...prevState.skeletonViewItems, ...skeletonViewItems],
})); |
ProposalPlease re-state the problem that we are trying to solve in this issueTheme - Skeleton placeholder in LHN does not switch theme when device theme is switched What is the root cause of that problem?This is because we are generating skeleton view items onLayout call in What changes do you think we should make in order to solve the problem?
skeletonViewItems.push((theme, themeStyles) => (
<SkeletonViewContentLoader
key={`skeletonViewItems${i}`}
animate={this.props.shouldAnimate}
height={CONST.LHN_SKELETON_VIEW_ITEM_HEIGHT}
backgroundColor={theme.skeletonLHNIn}
foregroundColor={theme.skeletonLHNOut}
style={themeStyles.mr5}
>
<Circle
cx="40"
cy="32"
r="20"
/>
<Rect
x="72"
y="18"
width="20%"
height="8"
/>
<Rect
x="72"
y="38"
width={lineWidth}
height="8"
/>
</SkeletonViewContentLoader>
),
);
<View>{this.state.skeletonViewItems.map((value) => value(this.props.theme, this.props.themeStyles))}</View> What alternative solutions did you explore? (Optional) |
@grgia can you have a look please? |
ProposalPlease re-state the problem that we are trying to solve in this issue.Color of LHN skeleton view is not getting updated after changing theme. What is the root cause of that problem?Skeleton view items are generated on 'onLayoutEvent' of OptionsSkeletonView. And the OptionsSkeleton view is never unmounted even if we navigate away from the LHN view. Due to this the onLayout event never gets called again and the generated skeleton items retain the older theme color. What changes do you think we should make in order to solve the problem?The most appropriate fix for this issue is to move the skeleton item rendering logic into the render method itself. Then the skeleton items would automatically respond to theme changes with out force re-rendering. Add an onLayout method that would simply set skeletonViewItems to an array of required length onLayoutChange(event) {
const numItems = Math.ceil(event.nativeEvent.layout.height / CONST.LHN_SKELETON_VIEW_ITEM_HEIGHT);
this.setState({skeletonViewItems: Array.from({length: numItems})});
} Now update render method to render render() {
return (
<View
style={[this.props.themeStyles.flex1, this.props.themeStyles.overflowHidden]}
// update skeletonViewItems length on layout change
onLayout={this.onLayoutChange.bind(this)}
>
<View>
{this.state.skeletonViewItems.map((_, i) => (
<SkeletonViewContentLoader
key={`skeletonViewItems${i}`}
animate={this.props.shouldAnimate}
height={CONST.LHN_SKELETON_VIEW_ITEM_HEIGHT}
backgroundColor={this.props.theme.skeletonLHNIn}
foregroundColor={this.props.theme.skeletonLHNOut}
style={this.props.themeStyles.mr5}
>
<Circle
cx="40"
cy="32"
r="20"
/>
<Rect
x="72"
y="18"
width="20%"
height="8"
/>
<Rect
x="72"
y="38"
width={i % 3 === 0 ? '100%' : i % 3 == 1 ? '50%' : '25%'}
height="8"
/>
</SkeletonViewContentLoader>
))}
</View>
</View>
);
} This approach is much more concise, leaner and makes the component easier to be migrated to a functional component as it doesn't use any React lifecycle methods . Result result.mp4 |
Not a deploy blocker, lets resolve at the regular priority |
📣 @hoangzinh 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @ishpaul777 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
PR merged |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.20-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-01-09. 🎊 After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
BugZero Checklist:
|
@hoangzinh - I need you to accept the offer so I can pay you! Thanks for being on it with the checklist. |
Accepted. Thanks @sophiepintoraetz |
Issue is ready for payment but no BZ is assigned. @alexpensify you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks! |
Automation is wrong, it looks like @sophiepintoraetz is handling the party here. I'm unassigning myself. |
All paid. |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: v1.4.13-4
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause-Internal Team
Slack conversation: @
Action Performed:
(If on Android or iOS, directly switch the dark mode settings from notification panel)
Expected Result:
The skeleton placeholder in LHN will switch theme accordingly.
Actual Result:
The skeleton placeholder in LHN does not switch theme.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Bug6314470_1702642054976.bandicam_2023-12-15_12-17-28-430.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: