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

[🐞] prevUrl of the useLocation() is set even if the first view. #6625

Closed
genki opened this issue Jul 1, 2024 · 4 comments · Fixed by #7082
Closed

[🐞] prevUrl of the useLocation() is set even if the first view. #6625

genki opened this issue Jul 1, 2024 · 4 comments · Fixed by #7082
Labels
COMMUNITY: good first issue Good for newcomers COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it COMP: qwik-city TYPE: bug Something isn't working

Comments

@genki
Copy link
Contributor

genki commented Jul 1, 2024

Which component is affected?

Qwik City (routing)

Describe the bug

I have tried to detect the SPA navigation.
I expected the loc.prefUrl is undefined at the first render, but it is already set to the URL of the page at the very beginning.

Reproduction

https://stackblitz.com/edit/qwik-starter-q5hnsb?file=src%2Froutes%2Findex.tsx

Steps to reproduce

No response

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M2
    Memory: 93.28 MB / 24.00 GB
    Shell: 3.6.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.12.1 - /opt/homebrew/opt/node@20/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.5.0 - /opt/homebrew/opt/node@20/bin/npm
    pnpm: 9.3.0 - ~/Library/pnpm/pnpm
    bun: 1.1.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 17.5
  npmPackages:
    @builder.io/partytown: ^0.10.0 => 0.10.2 
    @builder.io/qwik: workspace:^ => 1.5.6 
    @builder.io/qwik-city: workspace:^ => 1.5.6 
    typescript: 5.4.5 => 5.4.5 
    undici: * => 6.6.2 
    vite: ^5.2.10 => 5.2.11

Additional Information

No response

@genki genki added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Jul 1, 2024
@gnemanja
Copy link
Contributor

This is why the documentation example doesn't work:
https://qwik.dev/docs/api/#going-back

@wmertens wmertens added COMMUNITY: good first issue Good for newcomers COMP: qwik-city COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it and removed STATUS-1: needs triage New issue which needs to be triaged labels Sep 14, 2024
@wmertens
Copy link
Member

Good point, PR welcome. The code is most likely inside qwik-city-component.tsx

@PatrickJS
Copy link
Member

you can use nav(-1) to go back.

the value might be set here

const prevUrl = routeLocation.url;
so PRs welcomed

@gioboa
Copy link
Member

gioboa commented Nov 21, 2024

I added this <a href="/user"> to go in a different page and in that page prevUrl.href is http://localhost:5173/user/
That's so weird 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMMUNITY: good first issue Good for newcomers COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it COMP: qwik-city TYPE: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants