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

[🐞] <Link scroll={false}... to same path still scrolls #6411

Open
williamsdyyz opened this issue May 27, 2024 · 7 comments
Open

[🐞] <Link scroll={false}... to same path still scrolls #6411

williamsdyyz opened this issue May 27, 2024 · 7 comments
Labels
COMP: qwik-city STATUS-2: requires discussion Requires further discussion before moving forward TYPE: bug Something isn't working WAITING FOR: user Further information is requested from the issue / pr opener

Comments

@williamsdyyz
Copy link
Contributor

williamsdyyz commented May 27, 2024

Which component is affected?

Qwik Runtime

Describe the bug

I'm trying to show dialog boxes based on a search param like
<Link href="./?dialog=about" scroll={false}>About us</Link>

I need the scroll position of the document to stay put when the user clicks the link. Unfortunately scroll={false} isn't doing that.

Reproduction

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

Steps to reproduce

  1. Run npm install & npm dev.
  2. Go to the /link-scroll route in the browser
  3. Scroll down
  4. Click any link
  5. Document scrolls to top

System Info

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: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @builder.io/qwik: ^1.4.3 => 1.4.3 
    @builder.io/qwik-city: ^1.4.3 => 1.4.3 
    typescript: 5.3.3 => 5.3.3 
    undici: 5.28.2 => 5.28.2 
    vite: 4.5.2 => 4.5.2

Additional Information

No response

@williamsdyyz williamsdyyz added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels May 27, 2024
@JerryWu1234
Copy link
Contributor

image

please help to check link

@williamsdyyz
Copy link
Contributor Author

@JerryWu1234 Link updated in the original post. Apologies, I'm not too familiar with Stackblitz

@maiieul
Copy link
Contributor

maiieul commented May 31, 2024

I can only see that in your stackblitz @williamsdyyz
image

@williamsdyyz
Copy link
Contributor Author

williamsdyyz commented May 31, 2024

Append /link-scroll to the address in the preview pane. The share link I created already had that. But I guess not. ¯_(ツ)_/¯
I also added a link on the first page since Stackblitz and I are having a disagreement.

@shairez
Copy link
Contributor

shairez commented Jun 1, 2024

thanks @williamsdyyz

So the purpose of the scroll value is for using the "back" button to go back to a route and have it "remember" the scroll position.

For navigating normally, it doesn't remember the scroll positions, only for going back in history.

Maybe this should be documented better?

@shairez shairez added WAITING FOR: user Further information is requested from the issue / pr opener COMP: qwik-city STATUS-2: requires discussion Requires further discussion before moving forward and removed STATUS-1: needs triage New issue which needs to be triaged labels Jun 1, 2024
@williamsdyyz
Copy link
Contributor Author

@shairez Interesting. False assumption on my part. That prop is not documented at all.

In that case, the issue changes somewhat. For the use-case of showing a modal dialog that can be closed with the back button (similar to Android UX), there is no way to stop the navigation to the dialog from scrolling the underlying document to top.

I've added an example to the link-scroll page: scroll down, click "Open dialog". The dialog appears but the document scrolls to top which is undesirable. The back button nicely closes the dialog and the scroll position is restored to where it should ideally have been all along.

I guess this is really a feature request, not a bug.

Is there any existing way to achieve what I need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP: qwik-city STATUS-2: requires discussion Requires further discussion before moving forward TYPE: bug Something isn't working WAITING FOR: user Further information is requested from the issue / pr opener
Projects
None yet
Development

No branches or pull requests

4 participants