Support navigating to hash URLs for in-page navigation
- Dominant language
- No language data
- Stars
- 801
- Forks
- 409
- PR merge metrics
- No merged PRs in 30d
Description
if supported, maybe hash / anchor / id navigation would look like this in user-land:
```ts
export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
constructor() {
super(...arguments);
this.on('routeDidChange', this.handleHashTarget);
}
willDestroy() {
this.off('routeDidChange', this.handleHashTarget);
}
@action
handleHashTarget() {
schedule('afterRender', () => later(this, 'scrollToId', 16));
}
@action
scrollToId() {
let id = this.location.hash;
if (id) {
document.getElementById(id)?.scrollIntoView();
}
}
}
```
(and then letting the actual router (router_js) handle `#` navigations. atm, the navigation look like:
```
Attempting URL transition to /my-route#hashId
Attempting URL transition to /my-route
```
It just drops the hash
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.