Skip to content
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

Using the router does not trigger :target pseudo class #2076

Closed
manniL opened this issue Dec 10, 2023 · 2 comments
Closed

Using the router does not trigger :target pseudo class #2076

manniL opened this issue Dec 10, 2023 · 2 comments

Comments

@manniL
Copy link

manniL commented Dec 10, 2023

Reproduction

https://stackblitz.com/edit/vue-router-2076

Steps to reproduce the bug

The CartAside component has CSS styles based on the :target pseudoclass. It is triggered by the links on the page.

  1. Click on "Open Cart via router link"
  2. See that the URL changes but the overlay does not open
  3. Click on Open Cart via a
  4. See that the URL stays (if you'd go from / it'd change correctly too) and the drawer opened

Same with the close links after the overlay.

Expected behavior

When using the RouterLink with an id (e.g. #cart), the :target pseudoclass styles should be triggered

Actual behavior

The :target styles are ignored.

Additional information

As a workaround, using <a> tags works fine 👍🏻

Related issue: nuxt/nuxt#24415

Copy link
Member

posva commented Dec 11, 2023

It's apparently okay, from vendors' perspective, for this not to work with pushState(). You can find some workarounds too at whatwg/html#639. Using the regular <a> tag for this seems fine too

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2023
@manniL
Copy link
Author

manniL commented Dec 11, 2023

Thanks for the quick insight 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants