Skip to content

Keyboard navigation is broken #1439

Open
@gkappen

Description

@gkappen

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 (<anonymous>)

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

const { route, model } = this.docsRoutes.previous;
if (model) {
  this.router.transitionTo(route, model);
} else {
  this.router.transitionTo(route);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions