-
Notifications
You must be signed in to change notification settings - Fork 219
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
Wrap the RecentSearches in ClientOnly #2188
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Size Change: +28 B (0%) Total Size: 850 kB
ℹ️ View Unchanged
|
sarayourfriend
approved these changes
May 25, 2023
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.
LGTM! This fix makes sense, especially as the component is only ever shown as a result of user interaction and is based on local storage data 👍
dhruvkb
approved these changes
May 25, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
💻 aspect: code
Concerns the software code in the repository
🛠 goal: fix
Bug fix
🟨 priority: medium
Not blocking but should be addressed soon
🧱 stack: frontend
Related to the Nuxt frontend
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
Fixes #473 by @obulat
Description
This PR fixes the client-server mismatch on the mobile.
When you open the server-rendered mobile search page (directly opening the address like localhost:8443/search/?q=cat, or refreshing the search page) instead of navigating to it from the homepage, the contents of the recent searches list from the server are different from the local list saved in the local storage. This causes a mismatch of the server-rendered layout and the client-rendered layout. Nuxt re-renders the layout completely instead of adding the event handlers to the server-rendered layout when "hydrating".
To prevent this, we use the
ClientOnly
wrapper component, which stops the Recent Searches from rendering on the server. Recent Searches on mobile will now only render on the client, after the server-rendered layout is ready. This will match the way it is done on desktop.Testing Instructions
Open the app on a narrow screen with mobile layout. Execute a search to fill in the local storage with some "recent searches. Then, go to localhost:8443/search/?q=openverse directly. You should not see the "client-server mismatch" error messages in the browser console.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin