Skip to content
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

Closed
6 tasks done
izarutskaya opened this issue Dec 15, 2023 · 38 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Dec 15, 2023

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:

  1. Log in to HT account (as it loads slower after login).
  2. While the skeleton loading is showing, go to Settings > Preferences > Theme.
    (If on Android or iOS, directly switch the dark mode settings from notification panel)
  3. Switch to a different mode (if light, then dark; if dark, then light).
  4. Close the RHP.

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?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6314470_1702642054976.bandicam_2023-12-15_12-17-28-430.mp4

Bug6314470_1702642093031!Screenshot_20231215-200423_New_Expensify

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016c5e43f31286b1d7
  • Upwork Job ID: 1735650839183564800
  • Last Price Increase: 2023-12-22
  • Automatic offers:
    • hoangzinh | Reviewer | 28069280
    • ishpaul777 | Contributor | 28069281
@izarutskaya izarutskaya added DeployBlockerCash This issue or pull request should block deployment External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 15, 2023
@melvin-bot melvin-bot bot changed the title Theme - Skeleton placeholder in LHN does not switch theme when device theme is switched [$500] Theme - Skeleton placeholder in LHN does not switch theme when device theme is switched Dec 15, 2023
Copy link

melvin-bot bot commented Dec 15, 2023

Triggered auto assignment to @sophiepintoraetz (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

Copy link

melvin-bot bot commented Dec 15, 2023

Job added to Upwork: https://www.upwork.com/jobs/~016c5e43f31286b1d7

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 15, 2023
Copy link

melvin-bot bot commented Dec 15, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

Copy link

melvin-bot bot commented Dec 15, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (External)

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Dec 15, 2023
Copy link
Contributor

👋 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:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

Copy link

melvin-bot bot commented Dec 15, 2023

Triggered auto assignment to @flodnv (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@ishpaul777
Copy link
Contributor

ishpaul777 commented Dec 15, 2023

Proposal

Problem

Skeleton placeholder in LHN does not switch theme when device theme is switched

Root Cause

we do have any logic to rerender the skeleton when theme changes so the skeleton no rerender in OptionsListSkeletonView

Changes

setup a componentdidUpdate to rerender the skeleton with correct theme when theme chages in OptionsListSkeletonView

 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],
        }));

@shubham1206agra
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue

Theme - 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 OptionsListSkeletonView. So this will not run again on changing theme.

What changes do you think we should make in order to solve the problem?

  1. Store component as a function that accepts theme and themestyles as argument, and use it as follows
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>
),
            );
  1. And use it as map in View where state are loading
<View>{this.state.skeletonViewItems.map((value) => value(this.props.theme, this.props.themeStyles))}</View>

What alternative solutions did you explore? (Optional)

@flodnv
Copy link
Contributor

flodnv commented Dec 15, 2023

@grgia can you have a look please?

@flodnv flodnv assigned grgia and unassigned flodnv Dec 15, 2023
@aswin-s
Copy link
Contributor

aswin-s commented Dec 15, 2023

Proposal

Please 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. OnLayout event is only used to find the number of skeleton items that should be rendered. So only do the numItems calculation on layout event. Move the logic to render SkeletonViewContentLoader into render method and remove the generateSkeletonViewItems altogether.

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 SkeletonViewContentLoader depending on the length of skeletonViewItems

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

@Julesssss Julesssss added Daily KSv2 and removed Hourly KSv2 DeployBlockerCash This issue or pull request should block deployment labels Dec 15, 2023
@Julesssss
Copy link
Contributor

Not a deploy blocker, lets resolve at the regular priority

@melvin-bot melvin-bot bot added the Overdue label Dec 18, 2023
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 25, 2023
Copy link

melvin-bot bot commented Dec 25, 2023

📣 @hoangzinh 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Dec 25, 2023

📣 @ishpaul777 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Dec 25, 2023
@iwiznia iwiznia removed their assignment Dec 26, 2023
@roryabraham
Copy link
Contributor

PR merged

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 2, 2024
@melvin-bot melvin-bot bot changed the title [$500] Theme - Skeleton placeholder in LHN does not switch theme when device theme is switched [HOLD for payment 2024-01-09] [$500] Theme - Skeleton placeholder in LHN does not switch theme when device theme is switched Jan 2, 2024
Copy link

melvin-bot bot commented Jan 2, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 2, 2024
Copy link

melvin-bot bot commented Jan 2, 2024

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.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jan 2, 2024

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:

  • [@hoangzinh] The PR that introduced the bug has been identified. Link to the PR:
  • [@hoangzinh] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@hoangzinh] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@hoangzinh] Determine if we should create a regression test for this bug.
  • [@hoangzinh] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@sophiepintoraetz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@hoangzinh
Copy link
Contributor

BugZero Checklist:

  • The PR that introduced the bug has been identified. Link to the PR: New skeleton loader for LHN #14456
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: https://github.com/Expensify/App/pull/14456/files#r1430364997
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
  • Determine if we should create a regression test for this bug: 🚫 Nope I think. This is a UI issue and it's an edge case when loading the app as well (HT account + network is slow + the user would like to switch theme during loading time)

@sophiepintoraetz
Copy link
Contributor

@hoangzinh - I need you to accept the offer so I can pay you! Thanks for being on it with the checklist.

@hoangzinh
Copy link
Contributor

Accepted. Thanks @sophiepintoraetz

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 9, 2024
Copy link

melvin-bot bot commented Jan 9, 2024

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!

@alexpensify
Copy link
Contributor

Automation is wrong, it looks like @sophiepintoraetz is handling the party here. I'm unassigning myself.

@alexpensify alexpensify removed their assignment Jan 9, 2024
@sophiepintoraetz
Copy link
Contributor

All paid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests