vue-2-crumbs icon indicating copy to clipboard operation
vue-2-crumbs copied to clipboard

'route' watch triggered after 'created' hook

Open jorups opened this issue 6 years ago • 7 comments

Using 'parentsList' for dynamic breadcrumbs '$route' watch is triggered after 'breadcrumbChanged' event when navigating using router.push/router.replace. As '$route' watch clears 'parentsDynamicRoutes' therefore only current breadcrumb is generated not the full trail.

jorups avatar Sep 03 '18 17:09 jorups

@jorups Thank you for a report! I will try to find free time to fix it

Suruat avatar Sep 05 '18 15:09 Suruat

Hi, @jorups !

Can you provide reproduction link for this issue. As I see, 'breadcrumbChanged' event triggered before and after watcher for $route.

Thank you in advance

Suruat avatar Sep 08 '18 08:09 Suruat

I think that is the case when breadcrumb is a function, like when the route contains multiple /:variables.

luckydonald avatar Nov 07 '18 21:11 luckydonald

The fix seems to be replacing

  watch: {
    $route() {
      // Set empty component's 'parentsDynamicRoutes' property on each route change
      this.parentsDynamicRoutes = [];
    },
  },

with

  beforeRouteUpdate() {
    // Set empty component's 'parentsDynamicRoutes' property on each route change
    this.parentsDynamicRoutes = [];
  },

Edit: Hmm, that doesn't work when jumping to / home.

luckydonald avatar Nov 07 '18 23:11 luckydonald

Also hot reload empties that list.

luckydonald avatar Nov 07 '18 23:11 luckydonald

I get the same behaviour, was there a fix for this?

rosshulford avatar Mar 04 '19 11:03 rosshulford

@rosshulford No, there wasn't. Can you provide reproduction link for this issue?

Suruat avatar Mar 04 '19 14:03 Suruat