-
Notifications
You must be signed in to change notification settings - Fork 749
feat: allow skipping scrolling on partial navigation #3817
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import { INTERNAL_PREFIX, PARTIAL_SEARCH_PARAM } from "../../constants.ts"; | ||
|
|
||
| export const PARTIAL_ATTR = "f-partial"; | ||
| export const PARTIAL_NO_SCROLL_ATTR = "f-dont-scroll"; | ||
|
|
||
| class NoPartialsError extends Error {} | ||
|
|
||
|
|
@@ -170,7 +171,9 @@ | |
| await fetchPartials(nextUrl, partialUrl, true); | ||
| updateLinks(nextUrl); | ||
| }); | ||
| scrollTo({ left: 0, top: 0, behavior: "instant" }); | ||
| if (!el.hasAttribute(PARTIAL_NO_SCROLL_ATTR)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: this reads the attribute off the anchor itself, not ancestors — that's consistent with how
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, thinking about it, I wonder if f-partial on should not scroll to top by default at all Because I don't think I have found any use-case when , a mechanism for explicitly updating a PART of the page needs to scroll
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd lean toward shipping this as-is (opt-out) rather than flipping the default in this PR. Changing scroll-to-top to off-by-default is a behavior change every existing The opt-out shape ( Happy to revisit the default in a follow-up if there's appetite for it. |
||
| scrollTo({ left: 0, top: 0, behavior: "instant" }); | ||
| } | ||
| } finally { | ||
| if (indicator !== undefined) { | ||
| indicator.value = false; | ||
|
|
@@ -415,7 +418,7 @@ | |
| for (let i = 0; i < json.islands.length; i++) { | ||
| const island = json.islands[i]; | ||
| promises.push( | ||
| import(/* @vite-ignore */ island.chunk).then((mod) => { | ||
| ISLAND_REGISTRY.set(island.name, mod[island.exportName]); | ||
| }), | ||
| ); | ||
|
|
||
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.
Could we rename this to
f-no-scroll? It's a bit out of step with the rest of Fresh's attribute vocabulary (f-partial,f-client-nav) — all existing ones are positive nouns without contractions.