-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Router: event listener on internal links is overly broad #591
Comments
Not sure how to tackle this issue yet, but we should consider it before 1.0.0 release since this might cause breaking changes on how links work. |
@kiaking Should we introduce a new attribute |
Hmmm... This issue is a little related to #199, where this is about CSS but it's kinda same in a way that it would be great to have a "scoping" feature in the doc theme. In that sense, maybe it might be better to introduce a block element or custom component for this...? Something like: <Raw>
<MyComponent />
</Raw> And we ignore everything inside And to do that, I think adding |
Using Like @egardner (and me 😄), there will be cases where VitePress will get used for component demo, and adding Sorry, I don't have a solution to share this at the moment. |
So here is my solution (workaround) for CSS isolation: #199 (comment) We probably should just check for |
Describe the bug
We are using Vitepress to power a documentation and demo site for a UI library (https://doc.wikimedia.org/codex/main/), as an alternative to Storybook.
Recently I created a new page to demonstrate a tabbed layout component, which makes use of some internal links (with
@click.prevent
applied) for semantic/accessibility purposes. I was surprised to see that the demo page contained some unanticipated behavior – clicking a tab caused the page to jump around and updated the URL with a fragment ID.This is happening because the Vitepress router introduces a global event listener for all internal link elements on the page, adding some extra behavior (updating the URL hash, scrolling the target element into view). This makes sense for heading or section elements on the page, but it's being applied everywhere.
Is there any way to scope this to be a little more specific? Maybe this handler should only apply to headings or section elements, or should only target elements that have been created by Vitepress as part of the page theme?
Reproduction
Behavior can be seen here: https://772516--wikimedia-codex.netlify.app/components/tabs.html – click a tab in one of the demo components and watch the page jump around.
Expected behavior
Not expecting additional behavior to be added to links inside embedded demo components on pages.
System Info
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: