Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

AP-1075 Fix spinner remounting restarts #137

Merged
merged 2 commits into from
Nov 18, 2019

Conversation

jgzuke
Copy link
Contributor

@jgzuke jgzuke commented Nov 15, 2019

Take the approach outlined in https://dev.to/selbekk/how-to-stop-your-spinner-from-jumping-in-react-5cmp to stop the spinner from restarting the animation when remounted. This should fix the loader animation restarts described in https://apollographql.atlassian.net/browse/AP-1075.

This worked writing a local story that remounted the component but I was having a really rough time trying to get the linked version to run properly so 🙏 it works properly in that situation as well.

@jgzuke jgzuke requested a review from justinanastos November 15, 2019 01:43
@justinanastos justinanastos added the minor Increment the minor version when merged label Nov 15, 2019
Copy link
Contributor

@justinanastos justinanastos left a comment

Choose a reason for hiding this comment

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

Good work @jgzuke ! The CI failure for check-label is two pronged; first, it's broken because I disabled it but didn't disable it everywhere (my mistake! Fixing in #138). Second, you need to add a label so we can automatically categorize the PR. I added minor for you.

Second, this breaks our chromatic stories because it introduces timing issues. Chromatic, by default, disables css animations so that our visual tests will be consistent run to run, this will change them based on how long the tests take to run. I left a comment explaining how to fix this. Fix it, let me review really quick, and let's get this merged.

Also, please elaborate on why you couldn't test this in AGM. If the readme instructions don't work then let's update them so they do work! Also, and we should avoid this is if we can, we can use npx auto canary to publish a canary build that we can npm install in engine for testing. We should be able to use npm link. One thing that might be causing issues is that the ./run command in AGM automatically runs npm install, which will remove your npm link. There's an environmental variable you can set, SKIP_NPM_INSTALL that will skip the npm install and keep your npm link intact. Give it a whirl!

@@ -73,6 +73,9 @@ export const LoadingSpinner: React.FC<Props> = ({

const pixelSize = SIZE_MAP[size];

const mountTime = React.useRef(Date.now());
const mountDelay = -(mountTime.current % 540);
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to disable this for chromatic testing. Fortunately, Chromatic prescribes a way to do this (https://docs.chromaticqa.com/ignoring-elements):

import isChromatic from 'storybook-chromatic/isChromatic';

You can check the source and see that it checks the user agent, which is a trivial amount of code to add so I'm ok with it.

const mountDelay = isChromatic() ? 0 : -(mountTime.current % 540);

@justinanastos
Copy link
Contributor

Rebase or merge against master to fix the CI failure! Sorry about that!

@jgzuke
Copy link
Contributor Author

jgzuke commented Nov 15, 2019

Yep I was linking with the npm install skipped, but getting hooks errors from react version mismatches since I believe the dependencies dont get synced the same when linking. I think just pinning the versions should fix it though. Will make the chromatic change

@jgzuke jgzuke force-pushed the jgzuke/fix-spinner-remounting-jank branch from 14d07f1 to 31d04cc Compare November 15, 2019 21:44
@jgzuke
Copy link
Contributor Author

jgzuke commented Nov 15, 2019

Got the link to work, it looks good in engine 👍

@jgzuke jgzuke requested a review from justinanastos November 15, 2019 21:44
@justinanastos
Copy link
Contributor

Great job @jgzuke , LGTM!

@jgzuke jgzuke force-pushed the jgzuke/fix-spinner-remounting-jank branch from 31d04cc to 8431303 Compare November 18, 2019 19:05
@jgzuke jgzuke merged commit acc6bea into master Nov 18, 2019
@jgzuke jgzuke deleted the jgzuke/fix-spinner-remounting-jank branch November 18, 2019 20:17
@apollo-bot2
Copy link
Collaborator

🚀 PR was released in v2.16.0 🚀

@apollo-bot2 apollo-bot2 added the released This issue/pull request has been released. label Nov 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants