-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
Linking to anchors does not scroll to point on page #228
Comments
Related to #202, in general linking is limited this way. I think support for anchors may need to be added to the Ember router itself. |
I consider this a bug as long as we append |
If anyone is looking for a cheap fix until this is properly solved, you can reopen the route class in an initializer and implement scrolling the anchor into view: Route.reopen({
afterModel() {
this._super(...arguments);
scheduleOnce('afterRender', null, () => {
if (location.hash.length) {
const anchor = document.querySelector(`a[href="${location.hash}"`);
if (anchor) {
anchor.scrollIntoView();
}
}
});
}
}) It's not pretty but works for me |
@makepanic if you want to PR this I'd accept it, I think it's better than what we have now! |
Say you copy a link to a specific anchor on a page, such as:
https://ember-decorators.github.io/ember-decorators/latest/docs/api/modules/@ember-decorators/service#service
The user would expect that loading this URL in a new tab would automatically scroll you to the
#service
anchor on the page. But it doesn't seem to; it seems to keep me at the top of the page. I assume this is because of the way the page loads, how that anchor is not present at first.If possible, it could be nice to do some JS magic to scroll down to that appropriate point on the page once the page is loaded!
The text was updated successfully, but these errors were encountered: