solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.14k stars 146 forks source link

[Bug] MemoryRouter - `set()` can't change the page #393

Closed birkskyum closed 6 months ago

birkskyum commented 6 months ago

Describe the bug

While writing docs for MemoryRouter, I got a bit concerned that the MemoryRouter might be entirely broken.

The set function in the MemoHistory appear to not be working as expected.

Using the set I expected to be able to do either of these:

Your Example Website or App

https://stackblitz.com/edit/github-xo9s9c-ljydbz?file=src%2Fapp.tsx

Steps to Reproduce the Bug or Issue

See description.

What works is going to an id hash if you're already on the right page. This can be shown in the demo by clicking to "About" link (the normal A link), and then the memo router button with /about#hash title)

Nothing else works how I expect it to.

The navigation can be fixed by triggering the listeners inside set i.e. right over the if (scroll), but I still can't make a page change AND do the scroll to the id hash in one button click.

Expected behavior

I'd expect to be able to use set to move between pages, since there's no alternative API than:

get, set, listen, go/back/forward

Screenshots or Videos

No response

Platform

but also stackblitz

Additional context

No response