ember-engines: route#refresh no longer works

App demoing that this.refresh() in an engine route works in ember 3.5.1, but not ember 3.6

Never calls model hook: https://github.com/amk221/-ember-engine-refresh-route/commit/71dd1b606e5a33d01ede516aa6936bc5b2683b1d#diff-394600f34d48dad6f0abc29af03d8b1bR5

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

Tried with ember-source 3.9.0 and works 👌

Ran into this myself, so I did some digging and found the problem – I’m not used to debugging Ember itself so apologies in advance if I fudge the explanation/terms a bit.

The tricky bit is here, in router.js’s NamedTransitionIntent class:

    // ...

    // Pivot handlers are provided for refresh transitions
    if (this.pivotHandler) {
      for (i = 0, len = parsedHandlers.length; i < len; ++i) {
        if (parsedHandlers[i].handler === this.pivotHandler.routeName) {
          invalidateIndex = i;
          break;
        }
      }
    }

    // ...

What’s happening is parsedHandlers uses the full route name, like so:

pivothandler-welp1

…but it’s comparing it to pivotHandler.routeName, which is the relative name of the route in Engine-land:

pivothandler-welp2

[Apologies for the shoddy screenshots. In the 2nd screen, fullRouteName is “home.tenant.analytics.interact”]

For ember-engines we need to compare it to pivotHandler.fullRouteName instead. I did a quick-hack fix in my local dev environment and confirmed that this fixes the issue (and the infinite loop @thec0keman found – it’s indeed the same root issue).

Since fullRouteName is an ember-engines-specific extension, it’ll probably be necessary to extend NamedTransitionIntent to do this, I presume? Might be best to get a second opinion from a proper dev before attempting a PR just yet.