ember-meta icon indicating copy to clipboard operation
ember-meta copied to clipboard

Ignores transitions within the same route

Open lolmaus opened this issue 3 years ago • 1 comments

A transition can happen within the same route, e. g. when query params change or a route segment changes.

We properly update metaInfo:

  afterModel(model: ProjectsProjectRouteModel): void {
    this.metaInfo = {
      title: model.project.attributes.metaTitle ?? model.project.attributes.companyName,
      description: model.project.attributes.projectType,
      imgSrc: model.project.attributes.hero,
    };
  }

But the headData service ignores that because it only observes changes to routeName: https://github.com/shipshapecode/ember-meta/blob/main/addon/services/head-data.js#L16

My workaround is to do this after updating this.metaInfo:

    notifyPropertyChange(this.headData, 'routeName');
  }

This obviously is uboptimal. Changes to metaInfo should be tracked. Or it could be a method call, e. g. this.headData.setMetaInfo({})....

lolmaus avatar Feb 02 '22 17:02 lolmaus

@lolmaus good catch. We could probably make metaInfo a tracked built in or something. What do you think the best solution is?

RobbieTheWagner avatar Feb 02 '22 18:02 RobbieTheWagner