brisa-build / brisa

The Web Platform Framework.
https://brisa.build
MIT License
449 stars 12 forks source link

Navigate to the same page performs a full reload #560

Closed AlbertSabate closed 1 month ago

AlbertSabate commented 1 month ago

Describe the bug When you are in page / and have a link to /. This performs a full reload.

Expected behavior Should not do anything? Should only navigate to the top and trigger navigate events?

aralroca commented 1 month ago

I think is for this:

https://developer.mozilla.org/en-US/docs/Web/API/NavigateEvent/canIntercept

That is used here:

https://github.com/brisa-build/brisa/blob/9693d60a8dd353f899e4f17cab098243ae123250/packages/brisa/src/utils/rpc/rpc.ts#L111 Many things it does are right and we want them. But it also says this:

intercept the navigation if only the fragment portion differs.

Before implementing something, it would be good to know what other frameworks do in this case. I also don't see it problematic a normal navigation without SPA in this case, making it do nothing would be worse as user feedback I think. In which cases do you want to navigate to the same page without updating parameters or anything?

aralroca commented 1 month ago

Next.js what it does is to scroll up the page and nothing else, nothing is saved to navigation history

AlbertSabate commented 1 month ago

My concern of triggering native reload are as follows:

While it is not very serious issue, and should not be priority, I think we should think in how to make it better. NextJS approach is what I would be expecting.

nabby27 commented 1 month ago

I've created a $20 bounty for someone in the community to solve this issue so you can focus on more important tasks!

mobley-trent commented 1 month ago

I'd like to work on this @AlbertSabate

aralroca commented 1 month ago

@mobley-trent feel free to PR!

AlbertSabate commented 1 month ago

It would be awesome to receive and review your PR. If you need any guidance, feel free to ask on this thread, and we will be doing our best to guide you. :)

aralroca commented 1 month ago

I pre-released 0.1.3-canary.1 with this change. Thanks for the contribution @mobley-trent

nabby27 commented 1 month ago

I've already paid the bounty, congrats @mobley-trent, great job! 👏🏼