-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
property in anchor element forces a reload of the target #8153
Conversation
🦋 Changeset detectedLatest commit: 52606a3 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Want to bikeshed on the name a little bit. Just did a check:
Could not find other examples. |
force-load? |
Maybe |
Given our current directives related to this are all Although… would clicking a link with this property override any Do we have a description of use cases somewhere? Those might help with naming. |
@delucis This just means you want to opt-out of client-side routing for a particular link. One use-case is that the link goes to a file rather than another page, for ex. Note that directives are used for server-side processing in some way; |
SvelteKit uses Could also think ahead how this plays if we want to make prefetch first-class in the future |
Yeah, if we’re reasonably happy with how |
What about |
I think I'm coming around to just using |
There are only two hard things in Computer Science: cache invalidation and naming things. My 2ct I won’t use “transition” because technically it is not mainly about visual transition but whether or not the document is updated with new content (swap) or replaced by a new document. There could also be swap without transition. link would sound good to me but none of the defined values (https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel) seem to fit our purpose another try: These would also express that we leave it to to browser to choose viewers based on content-type |
@@ -276,6 +276,7 @@ const { fallback = 'animate' } = Astro.props as Props; | |||
if ( | |||
link && | |||
link instanceof HTMLAnchorElement && | |||
(link.dataset.astroReload ?? 'false') === 'false' && |
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.
is there a reason why someone would use a false value here? If not I think we can just check for its existence to save a few bytes.
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.
For me it looks odd if someone writes: reload="false"
and gets a reload.
But at the end it is a matter of documentation: "Any value assigned to this attribute is ignored."
10 Bytes saved :-) !
I think given the lack of great options we should just stick with |
I'm changing the base of this to I'm going to document this as part of withastro/docs#4320 |
@martrapp would you mind resolving this conflict? I would do it but it's part of the code that you most recently updated. Once that's done this is ready to be merged. Thanks! |
* swap attributes of the root element * + changeset
Changes
In an anchor element, the
data-astro-reload
property (with no value or with a value other than'false'
) forces a reload of the target document (instead of a view transition).Closes #7947
Testing
manually tested on the example given in #7947, outcome documented there.
[update 2023-08-22]: added e2e test
Docs
The documentation of the (still experimental) View Transitions needs to be updated.
Not sure if the data property will be the final interface for users or if there will be syntactic sugar (e.g.
transition:reload
).I plan to add one or more properties in the next few days to address other issues, in particular a property to control cross-page scrolling behavior (as opposed to on-page scrolling behavior)
/cc @withastro/maintainers-docs for feedback!