-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Migration Flow: Fix multiple stickers being added simultaneously when navigating to the "DIY" option #95612
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~27 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
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.
Thanks @m1r0! In my tests, it seems the issue was fixed! 🙌
I just left some suggestions in the code.
@@ -1,8 +1,9 @@ | |||
import { StepContainer } from '@automattic/onboarding'; | |||
import { useTranslate } from 'i18n-calypso'; | |||
import { FC, useMemo } from 'react'; | |||
import { FC, useMemo, useState } from 'react'; |
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.
The component SiteMigrationHowToMigrate
is getting a little complex (big). I started extracting part of the logic to another hook here. I think it would be nice to base this PR there and also add the loading logic there, returning the loading state. WDYT?
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.
Sounds good!
I've updated the code but I'm a bit unsure if my implementation is aligned with your vision. 😅 Could you give it a look again?
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.
Yes! That looks great!
.../stepper/declarative-flow/internals/steps-repository/site-migration-how-to-migrate/index.tsx
Outdated
Show resolved
Hide resolved
.../stepper/declarative-flow/internals/steps-repository/site-migration-how-to-migrate/index.tsx
Outdated
Show resolved
Hide resolved
@@ -1,8 +1,9 @@ | |||
import { StepContainer } from '@automattic/onboarding'; | |||
import { useTranslate } from 'i18n-calypso'; | |||
import { FC, useMemo } from 'react'; | |||
import { FC, useMemo, useState } from 'react'; |
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.
And I thought of another scenario where we could have the same race condition issue.
If the user is in a slow connection and they click on one of the options quickly it would be registering the "pending" sticker, and could try to register the "pending-{TYPE}" at the same time.
If we rebase this PR, we could also add the loader for this scenario (when creating the first "pending" sticker).
If we follow the suggestion of the other comment, I think it would assume this behavior automatically.
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 think I've managed to fix this scenario but I'm facing an issue with the component loading first and then the loader appearing.
aAeTa2.mp4
Can I fix this without having an extra state in the component?
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! I noticed that it's because this fetch depends on the siteId
, and it's taking some time to be ready because it's coming from the store. I wonder if we could get it directly from the query string, so we would have this information immediately when the component is loaded to start already with the loader. WDYT?
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.
Could you take a look at this approach? I wasn't able to avoid the site loading because of this check. Do you think it's good enough? 🙂
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 approach looks good to me!
But I just noticed another flickering after clicking on the options ("Do it for me", for example). It finishes the loading (the sticker creating that comes from the click), and displays the step again very quickly before calling the onSubmit
.
Screen.Recording.2024-10-28.at.13.02.34.mov
I think we'll probably need an extra state here, similar to your previous approach. Maybe something that we set as loading after clicking and keep this state unchanged, so onSubmit
is called when it's still in the loading state.
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 didn't noticed that one. I've fixed it here following your suggestion. Thank you for your patience!
080cdb6
to
df6a9e0
Compare
@renatho, I've noticed that I've broken some of the tests. I'll fix those once I have your approval for the implementation approach. 🙂 |
.../stepper/declarative-flow/internals/steps-repository/site-migration-how-to-migrate/index.tsx
Outdated
Show resolved
Hide resolved
@@ -1,8 +1,9 @@ | |||
import { StepContainer } from '@automattic/onboarding'; | |||
import { useTranslate } from 'i18n-calypso'; | |||
import { FC, useMemo } from 'react'; | |||
import { FC, useMemo, useState } from 'react'; |
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.
Yes! That looks great!
.../stepper/declarative-flow/internals/steps-repository/site-migration-how-to-migrate/index.tsx
Outdated
Show resolved
Hide resolved
@@ -1,8 +1,9 @@ | |||
import { StepContainer } from '@automattic/onboarding'; | |||
import { useTranslate } from 'i18n-calypso'; | |||
import { FC, useMemo } from 'react'; | |||
import { FC, useMemo, useState } from 'react'; |
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! I noticed that it's because this fetch depends on the siteId
, and it's taking some time to be ready because it's coming from the store. I wonder if we could get it directly from the query string, so we would have this information immediately when the component is loaded to start already with the loader. WDYT?
We are having page flickering, probably due to the I suggest showing the content only when we are ready to show it, preventing any future race conditions. |
@gabrielcaires, do you mean replacing the whole page content, not just the step content? |
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 and works well!
I'm already approving, but pinging @gabrielcaires to check if he has anything else to add based on his last comment.
Merging to unblock a potential refactor. |
Resolves #95560
Proposed Changes
Why are these changes being made?
Testing Instructions
/setup/migration
.migration-started-diy
sticker is present.Pre-merge Checklist