-
Notifications
You must be signed in to change notification settings - Fork 595
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 anchors ignored #666
Comments
This is expected behavior. From the https://choo.io/docs/routing page:
You'll need to do one of those things in order to get choo to stop routing on that link. (Please re-open this issue if you're still experiencing problems!) |
Gonna re-open this one since this functionality is actually meant to be supported. From the choo docs:
That said, sounds like this functionality never actually got built-out: scroll down to Clicking Anchors. |
I've ran in to this a couple of times, usually resolved it by adding a route for capturing anchors: app.route('/pages/:anchor', require('./pages-listing-or-single-page')) But that means that I can only support hash anchors at one level and they'd conflict with other path partials. E.g. this is what I'd like to do but it would totally not work (due to conflicting routes and multiple wildcards) but it'd be neat to support anchors at any and all routes without hacks: app.route('/pages/:anchor', require('./pages-listing')) // -> /pages#page01-heading
app.route('/pages/:page', require('./singe-page')) // -> /pages/page01
app.route('/pages/:page/:anchor', require('./singe-page')) // -> /pages/page01#heading IMO hash routing is an edge case only applicable for legacy browsers and for mounting the application at a path instead of site root, and should therefore be opt-in. |
@tornqvist Ya I had ended up doing the same in my app, luckily there was no conflicting sub-route. While it's interesting for the router to support both hash and non-hash together, not totally sure when you'd really need it, and even the dox discourage it:
opt-in hash routing seems like a decent move to me too! |
As far as I can tell, the behavior described in the docs (to scroll to a matching id if it exists, otherwise route) is still not what happens. I've opted into hash routing, and my hash links are not working as anchors. EDIT: Which is strange, because this example seems to work: https://choo-hash-anchors-enabled.glitch.me/my/app#footer. I'm on choo 7.0 |
As stated in readme (https://github.com/choojs/choo#hash-routing)
The linked example actually exemplifies how it doesn't work. Regardless of what path you're on, when kicking on the |
Expected behavior
When an anchor tag with a hash route is clicked,
<a href="#page-anchor">Jump To</a>
, the page should first be checked to see if an available page anchor exists and update scroll. Only if a page anchor is not found should a route change be triggered. Basing this off of https://github.com/choojs/choo#hash-routing and https://choo.io/docs/routingActual behavior
Route change is always triggered and no jump-to behavior is possible
Example
demo: https://choo-hash-bug.glitch.me/
code: https://glitch.com/edit/#!/choo-hash-bug?path=index.js:17:23
Curious if anyone else has ran into this? ✌️
The text was updated successfully, but these errors were encountered: