ember-learn / ember-learn/ember-cli-addon-docs
Keyboard navigation is broken
- Lingua principale
- JavaScript
- Stelle
- 172
- Fork
- 142
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Keyboard navigation (using `ArrowLeft` and `ArrowRight` to go to the previous or next topic) is broken on any site created using this addon. You can check it out by going to any topic on this addons own docs and pressing one of the arrow keys.
The resulting error is something like this:
```
Uncaught Error: More context objects were passed than there are dynamic segments for the route: docs.usage
at I.applyToHandlers (vendor-907f1d49045ce1b9b3f2f6d948b40f39.js:46691:15)
at I.applyToState (vendor-907f1d49045ce1b9b3f2f6d948b40f39.js:46628:19)
at s.applyIntent (vendor-907f1d49045ce1b9b3f2f6d948b40f39.js:47510:21)
at R (vendor-907f1d49045ce1b9b3f2f6d948b40f39.js:28701:45)
at r._prepareQueryParams (vendor-907f1d49045ce1b9b3f2f6d948b40f39.js:28260:19)
at r._doTransition (vendor-907f1d49045ce1b9b3f2f6d948b40f39.js:28219:12)
at h.transitionTo (vendor-907f1d49045ce1b9b3f2f6d948b40f39.js:27027:37)
at i.nextPage (vendor-907f1d49045ce1b9b3f2f6d948b40f39.js:81107:23)
at chunk.21.0381709c1e24f2a2857d.js:2:117294
at Array.forEach ()
```
The offending code seems to be at https://github.com/ember-learn/ember-cli-addon-docs/blob/daeaf9f909328ba92b106031b992bb085b96c23d/addon/components/docs-viewer/index.js#L55..L56 and https://github.com/ember-learn/ember-cli-addon-docs/blob/daeaf9f909328ba92b106031b992bb085b96c23d/addon/components/docs-viewer/index.js#L66..L67.
The fix seems fairly easy; If the `model` on a route is `undefined` the `transitionTo` method should not be called with the model argument.
Changing the code to the following fixes it, but I don't know if this might have side effects
```js
const { route, model } = this.docsRoutes.previous;
if (model) {
this.router.transitionTo(route, model);
} else {
this.router.transitionTo(route);
}
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inspect addon/components/docs-viewer/index.js at the referenced lines and reproduce the failure by using ArrowLeft or ArrowRight on a topic in the addon documentation. Check the previous and next route transitions when the model is undefined. Done means both keyboard directions navigate successfully without the dynamic-segments error.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- frontend
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100