Skip to content

Anchor with #hash not showing :target CSS after history.back() #10550

@hyunbinseo

Description

@hyunbinseo

Describe the bug

  1. Goto /#target
  2. Goto /temp
  3. Return to the previous page
  4. URL is /#target and the #target:target styles are not shown.

In this state, clicking <a href="#target"> should show #target:target styles, but it does not.

Reproduction

https://stackblitz.com/edit/github-ymws75?file=src%2Froutes%2F%2Bpage.svelte

System Info

  • Chrome 버전 115.0.5790.170(공식 빌드) (arm64)
  • Firefox 116.0.2 (64-비트)
System:
  OS: Linux 5.0 undefined
  CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 0 Bytes / 0 Bytes
  Shell: 1.0 - /bin/jsh
Binaries:
  Node: 16.20.0 - /usr/local/bin/node
  Yarn: 1.22.19 - /usr/local/bin/yarn
  npm: 9.4.2 - /usr/local/bin/npm
  pnpm: 8.6.10 - /usr/local/bin/pnpm
npmPackages:
  @sveltejs/adapter-auto: ^2.0.0 => 2.1.0 
  @sveltejs/kit: ^1.20.4 => 1.22.5 
  svelte: ^4.0.5 => 4.2.0 
  vite: ^4.4.2 => 4.4.9

Severity

annoyance

Additional Information

  1. Using <a href="#target" data-sveltekit-reload> fixes the :target CSS issue.
  2. Possibly related to Hash links to new pages don't focus the correct element #3770

Metadata

Metadata

Assignees

No one assigned

    Labels

    routerwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions