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.
Hi @ryyppy
As discussed, this PR is a suggestion for fixing the Syntax Lookup routing.
Notes
[1] I've tried to stay as close to the current implementation as possible and minimise changes, with one exception ...
[2] MAIN CHANGE: In the current code, when the search changes we have an effect to update the URL. In this PR I've reversed that, so when the URL changes it updates the search. I've tried to comment the flow of the code, see what you think.
[3] For route changes I'm using
Next.Router.push
so we get some history. Thereplace
behaviour has been removed (no longer needed due to point [2] above).[4] I've removed the
GithubSlugger.slug(item.id)
code. If we stick to the currentid
pattern using hyphenated lowercase names then I assume it's not needed? But let me know what you think.[5] I've added a
scrollToTop()
when the router triggers a Detail view. The only time this might feel a bit weird is when you have scrolled down the page a bit and manually type in the full name of an item.[6] BEHAVIOUR CHANGE: One behaviour change compared to the current implementation. If you are on a
ShowDetails
view and then change the search box, the URL anchor is not cleared.What do you think of this direction? Do you think that continuing with the current approach of syncing the route to the search (rather than syncing the search to the route) might be worth exploring more?
Testing
/syntax-lookup
shows theShowAll
view./syntax-lookup#module-decorator
shows theShowDetails
view.ShowDetails
view and sets the URL anchorShowAll
view and clears the URL anchorShowAll
view and clears the URL anchorShowFiltered
view, noting that the existing URL anchor remains unchanged.ShowDetails
view.ShowDetails
view consistently scrolls to the top.ShowDetails
andShowAll
views are retained.