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

Strange flicker on refresh #3682

Closed
maraisr opened this issue Nov 4, 2020 · 8 comments
Closed

Strange flicker on refresh #3682

maraisr opened this issue Nov 4, 2020 · 8 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@maraisr
Copy link

maraisr commented Nov 4, 2020

If you check the notes over at testing-library/testing-library-docs#661 which sent me here.

The rough idea is that the search boxs' keyboard hint flickers on windows.

@maraisr maraisr added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Nov 4, 2020
@lex111
Copy link
Contributor

lex111 commented Nov 4, 2020

Apparently you mean that the control key icon flickers on page load (because it changes depending on used OS).

@francoischalifour could you please suggest any options to avoid this?

@francoischalifour
Copy link
Contributor

Hey—this is due to how SSG and therefore Docusaurus (I believe) works. Let me know if I've misunderstood something.

Since a Docusaurus website gets generated on a server, we don't know yet what the user's OS will be, and therefore what shortcuts to display. We need to wait to load the page to have this information.

Hence, we change this shortcut in an effect.

Do you see any alternatives to avoid this flickering? (A safer solution would be to not display shortcuts until we know for sure the browser we're using.)

@maraisr
Copy link
Author

maraisr commented Nov 4, 2020

Yeah i think that would be best—halt all OS specific things till client side. The same would also have been true for dark mode, light mode stuff (https://joshwcomeau.com/gatsby/dark-mode/).

Is this something easily done? I could help with a PR! 🤩

@lex111
Copy link
Contributor

lex111 commented Nov 4, 2020

@francoischalifour Yes, you are right, as I understand it is also relevant for Gatsby (preview TypeScript website with applied doc search v3 https://ts-with-algolia-search.vercel.app/ faces the same issue).

Do you see any alternatives to avoid this flickering? (A safer solution would be to not display shortcuts until we know for sure the browser we're using.)

Well, I think this is a good option.

@francoischalifour
Copy link
Contributor

Sounds good!

@maraisr Happy to receive a PR on the next branch to display .DocSearch-Button-Keys only once we get the navigator platform. 🙂

@slorber
Copy link
Collaborator

slorber commented Nov 4, 2020

Do you see any alternatives to avoid this flickering? (A safer solution would be to not display shortcuts until we know for sure the browser we're using.)

If there's a finite set of keys, it's could be possible to render all the keys, but only show one of them, thanks to OS-specific CSS?
The critical CSS is blocking so we are sure it's loaded before the input renders.

Not sure how reliable it would be to detect with CSS the OS though...

@slorber
Copy link
Collaborator

slorber commented Nov 4, 2020

CSS variables is also an option, for example same as dark mode, we'd inject a --docsearch-action-key variable in styles at js init time, and use it in a ::after { content: var() } ?

(may not work well for docusaurus due to lazy loading the js)

francoischalifour pushed a commit to algolia/docsearch that referenced this issue Nov 5, 2020
This fixes a UI flash issue on Windows where the <kbd>⌘</kbd> key shows up right before <kbd>Ctrl</kbd> when using SSG (like Docusaurus).

This happened because in these scenarii, the site is generated on a server, and we can't know yet what will the user's OS be.

Closes facebook/docusaurus#3682.
@lex111
Copy link
Contributor

lex111 commented Dec 8, 2020

Fixed in #3819.

@lex111 lex111 closed this as completed Dec 8, 2020
@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

5 participants