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

Replace FullScreen and FullContainer components with useLayout hook #1206

Merged
merged 9 commits into from
Jan 21, 2022

Conversation

eason9487
Copy link
Member

Changes proposed in this Pull Request:

Closes #311

  • Move layout CSS styles to primary css folder.
  • Implement the useLayout hook.
  • Replace all <FullScreen> and <FullContainer> with useLayout hook.
  • Move the CSS for hiding the <Spinner> of <Suspense> to global scope to globally prevent the flickering when initial loading GLA admin pages.
  • Use CSS approach instead to override #wpbody's inline margin-top. To prevent the flickering when overriding the margin-top.

Screenshots:

🎥 Full page layout

1

🎥 Full page layout with new WooCommerce navigation feature

2

🎥 Full content layout

3

🎥 Full content layout with new WooCommerce navigation feature

4

Detailed test instructions:

Full page layout

  1. Go to the Get started page /wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fstart
  2. Click "Set up free listings in Google" to enter the onboarding page in full-page layout.
    • The whole page should be the same visual result as before.
    • There should be no flickering above the header with "Get started with Google Listings & Ads" content. The flickering problem looks like this:
      Kapture 2022-01-18 at 18 42 00
  3. Refresh the current page.
    • The whole page should be the same visual result as before.
    • There should be no flickering above the header with "Get started with Google Listings & Ads" content.
  4. Go back to the Get started page. The full-page layout should not be applied.

Full content layout

  1. Go to the Dashboard page /wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard
  2. Click "Add paid campaign" to enter the campaign creation page in full-content layout.
    • The whole page should be the same visual result as before.
    • There should be no flickering above the header with "Create your paid campaign" content.
  3. Refresh the current page.
    • The whole page should be the same visual result as before.
    • There should be no flickering above the header with "Create your paid campaign" content.
  4. Go back to the Dashboard page. The full-content layout should not be applied.

The patch of hiding the <Spinner> of <Suspense>

  1. Go to any of GLA admin pages, for example, the Reports page.
  2. Refresh the current page.
  3. There should be no flickering above the navigation tab. The flickering problem looks like this:
    Kapture 2022-01-18 at 18 46 06

With new WooCommerce navigation

  1. Install and activate the WooCommerce Admin extension.
  2. Go to WC settings page to enable the new navigation feature /wp-admin/admin.php?page=wc-settings&tab=advanced&section=features
  3. Repeat the above tests with new WooCommerce navigation.

Additional details:

💡 Why move the workaround of hiding the initial loading spinner to global scope.

Changelog entry

Fix - Prevent page flickering when loading admin pages of this extension.

@eason9487 eason9487 requested a review from a team January 19, 2022 04:25
@eason9487 eason9487 self-assigned this Jan 19, 2022
@@ -0,0 +1,94 @@
/**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the CSS was moved from <FullScreen> and <FullContainer> and merged to a single file. It'd be easier to check the diff from this link.

Copy link
Member

@ianlin ianlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and all good. Using a custom hook is cleaner than before. 👍

  • ✅ Full page layout looks the same as before.
  • ✅ Full content layout looks the same as before.
  • ✅ There are no flickering in both layouts.
    • ❔ However I didn't see the flickering either when using develop branch.
  • ✅ There is no spinner when refreshing any of the GLA admin page
    • ❔ However I didn't see the spinner either when using develop branch.
  • ✅ The CSS approach to override margin-top of #wpbody instead of useWPBodyMarginOffsetEffect hook works as expected.
  • ✅ Everything works as expected when testing against the new WC navigation.
    • Side note: when using WC 6.1, there is no WC navigation settings in wp-admin/admin.php?page=wc-settings&tab=advanced&section=features, downgrading to WC 6.0 in order to test the above tasks against the new navigation.
  • ✅ Code is clean and easy to understand.
  • 💅 Left a non-blocking comment below.

js/src/hooks/useLayout.js Show resolved Hide resolved
@eason9487
Copy link
Member Author

eason9487 commented Jan 20, 2022

@ianlin, thanks for the review!

  • ✅ There are no flickering in both layouts.
    • ❔ However I didn't see the flickering either when using develop branch.
  • ✅ There is no spinner when refreshing any of the GLA admin page
    • ❔ However I didn't see the spinner either when using develop branch.

💡 The <Spinner> of <Suspense> was removed from WC-admin 2.9.0 and is included in WC 6.0. So if you're testing with WC 6.0+ or activated WC-admin extension 2.9.0+, it would not have the flickering problem.

The flickering does not always occur every time. Inserting a breakpoint would be easier to observe.

The <Spinner> of <Suspense>

  1. On the GLA dashboard page, add breakpoint of attribute modifications on <body>
    2022-01-20 19 19 12
  2. Refresh page.
    Kapture 2022-01-20 at 19 20 39

#wpbody's inline margin-top

  1. Similar to above, add breakpoint of attribute modifications on <div id="wpbody"> on the campaign creation page.
  2. Refresh page.
    Kapture 2022-01-20 at 19 23 03

@ianlin
Copy link
Member

ianlin commented Jan 21, 2022

@eason9487

💡 The of was removed from WC-admin 2.9.0 and is included in WC 6.0. So if you're testing with WC 6.0+ or activated WC-admin extension 2.9.0+, it would not have the flickering problem.

Thanks for sharing this info and the breakpoint tip! Now I can reproduce the flickering problem in develop branch and confirm the problem is fixed in this PR. 👍

@eason9487 eason9487 merged commit 66d2f92 into develop Jan 21, 2022
@eason9487 eason9487 deleted the tweak/311-use-layout branch January 21, 2022 05:04
tomalec added a commit that referenced this pull request Sep 2, 2024
as we no longer need its offset to do calculations removed in #1206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-implement <Full*> components as useLayout
2 participants