-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Error when opening with a encoded hash title #2599
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
Comments
Hmm, odd, this seemed to work as expected for me |
I think I could provide more information.
From my side, if I start the Codesandbox project and open this link above (with the hash title) directly, I will get an error:
at As the screenshot: and also the target header wasn't on focus as well. And I guess @bencodezen also reproduced this bug before, right? 😄 So is there any other possible way we could dig into it? Thanks. |
Interesting, I'll have to take a look at it again; I couldn't repro in Firefox, but it looks like you're using chrome so will try that instead |
After some digging, it seems like this is an issue with Looks like this line specifically is causing the issue: https://github.com/vuejs/vue-router/blob/dev/src/util/scroll.js#L146 I was able to fix it locally, will submit a PR as soon as I can. @bencodezen - if you could possibly migrate this issue to vue router, that'd be awesome! |
@posva Would you or someone else have any idea what's going on here? |
This is a limitation of the current implementation and I introduced the |
@posva - I was getting around the limitation using But even with that fix, Could this be a side affect of our async loading of components? |
I don't understand what |
This el: https://github.com/vuejs/vue-router/blob/dev/src/util/scroll.js#L146 And we can't make that change in vuepress, it'd have to be made in vue-router I believe |
I thought you were saying to call
decodeURIComponent at the location you shared in scroll.js. Did you mean something else?
It's important to note it will still fail in some browsers (like IE and Safari) in some scenarios (passing |
@posva it might be a bit easier to possibly do a zoom call or something to show you, but essentially, what I'm seeing is that when |
The scrollBehavior on load was introduced recently, so it might be a bug on vue-router's end. In that case, can you create a reproduction (https://jsfiddle.net/posva/9r6xhqbp/) and open a bug report so I can take a look? |
The final wrong position is
This document is used here. https://router.vuejs.org/guide/advanced/scroll-behavior.html#async-scrolling
|
https://codesandbox.io/s/sharp-brattain-o40hs?file=/src/main.js I tested many versions of vue-router. vue-router not call That way, it should be a problem with this |
Bug report
Steps to reproduce
Open a URL with a encoded (Chinese) hash title like:
https://ge2hg.sse.codesandbox.io/guide/#color-overrides-%E4%B8%AD%E6%96%87
Source code from codesandbox: https://codesandbox.io/s/vuepress-bug-20200906-ge2hg
What is expected?
The encoded hash name should be decoded properly I guess, and the target element should be on focus.
What is actually happening?
The target element didn't be focused on. Also, there is a JS error in the console.
it's probably because the hash name wasn't decoded before calling document.getElementById. But I couldn't dig much deeper into the code.
Other relevant information
npx vuepress info
in my VuePress project:The text was updated successfully, but these errors were encountered: