Interactivity API: Override unfinished navigate calls#54201
Conversation
|
Size Change: +207 B (0%) Total Size: 1.52 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 43556a0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6089995120
|
luisherranz
left a comment
There was a problem hiding this comment.
Very good test!! It's pretty smart 🙂
My only concern is why should we use url instead of href? (href also contains the hash)
packages/interactivity/src/router.js
Outdated
| // Navigate to a new page. | ||
| export const navigate = async ( href, options = {} ) => { | ||
| const url = cleanUrl( href ); | ||
| navigatingTo = url; |
There was a problem hiding this comment.
What's the logic for using url instead of href here?
There was a problem hiding this comment.
That's a good question. 😄 I think I assumed that, as the url would be the same for href with hashes, both navigations would wait for the same Promise so that they would happen in order and there would be no problem.
I missed considering that:
- You could use
forceand request the HTML again. - Both navigations would trigger a render, which is bad.
There was a problem hiding this comment.
Yeah, I think it's a bit safer this way. That way, the user will end up with the correct hash in the browser URL (even though we don't support scrolling to the id yet).
Thanks David!
luisherranz
left a comment
There was a problem hiding this comment.
Looks great, thanks David! 🙂
What?
Improve
navigate()to render only the result of the last call when multiple happen simultaneously.Why?
Required for the Query Loop block with enhanced pagination.
store()API #53740How?
Previous
navigate()calls are not canceled, so the related HTML is still fetched. However, only the last one executes Preact'srender().Testing Instructions