ember-meta
ember-meta copied to clipboard
Ignores transitions within the same route
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 good catch. We could probably make metaInfo a tracked built in or something. What do you think the best solution is?