-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
$page.url.hash
is not updated.
#9374
Comments
@Rich-Harris Just to brainstorm: one of the ways to deal with this is to update instances of the kit/packages/kit/src/runtime/client/client.js Lines 1693 to 1704 in f1beb92
This is where the magic should happen? 🤔 Accessing the stores via: kit/packages/kit/src/runtime/client/singletons.js Lines 16 to 21 in f1beb92
I've seen the other pr's related to the |
Here's what I've been trying: the But whenever i try to update the Lets say we update the page with the new hash on the addEventListener('hashchange', (event) => {
const new_url = new URL(event.newURL);
const old_url = new URL(event.oldURL);
// if the hashchange happened as a result of clicking on a link,
// code here...
// If the hash is the only thing that changed via user input, update the hash on the store
if (new_url.hash != old_url.hash) {
stores.page.set({ ...page, url: { ...page.url, hash: new_url.hash } });
stores.page.notify();
return;
} And this is the code for <script>
import { page } from '$app/stores';
$: console.log('Store', $page.url.hash);
</script>
<svelte:window
on:hashchange={() => {
console.log($page.url.hash, 'store');
console.log(window.location.hash, 'location');
}}
/>
If we replace
It's like |
Hello! Would a change such as this be acceptable?
It seems to work with shallow, manual tests, but I am not sure about other implications. Furthermore, I've been unable to write a Playwright test to change the address bar and check the value's change in a div whose content is $page.url. |
I think this may be the same bug I have run into in #10013 UPDATE: Doesn't appear so |
Describe the bug
When the URL hash value is changed using the address bar, the
$page
store is not updated.Reproduction
Checked on Chrome, Firefox, and Safari. Reference 'System Info' for version numbers.
#1
with#2
in the address bar.Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: