question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Override trigger template in v4

See original GitHub issue

First of all, thank you for the great effort spent on this addon.

In EPS v3 I was able to override the trigger template by having a template file templates/power-select/trigger.hbs. Now with v4 the addon switched to co-located templates, so the template is now at components/power-select/trigger.hbs. If I introduce a file at that location, Ember throws the following error:

Uncaught (in promise) TypeError: can’t redefine non-configurable property “default”

My guess is that having a file named components/power-select/trigger.hbs, I’m not actually overriding a template, but introducing a new component (shadowing the addon). How would I go about replacing the actual trigger template with v4?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Boukecommented, Jan 15, 2021

Cross-post from discuss.emberjs.com:

So I suppose the answer to my question is answered here: Build-time transformations:

One caveat here is that each component JavaScript file should export a value that is unique to that file. For example, this should be avoided :

// app/components/foo-bar.js

import MyParentComponent from "./my-parent";

// BAD: don't do this!
export default MyParentComponent;

This is problematic because setComponentTemplate will be called on MyParentComponent directly, affecting the parent component and all of its descendants. This can be avoided by subclassing, even when no customization is required:

// app/components/foo-bar.js

import MyParentComponent from "./my-parent";

// GOOD: do this instead!
export default class extends MyParentComponent {}

With that in mind, I’ve changed my code to read like this:

import Trigger from 'ember-power-select/components/power-select/trigger';
export default class extends Trigger { }

And now my custom template is being used!

As a separate issue I cannot seem to find the magical incantation to get TypeScript to allow the import. TypeScript insists on adding /addon/, which fails run time. This might be due to the following caveat listed in ember-cli-typescript:

  • Similarly, apps must use .js to override addon defaults in app , since the different file extension means apps no long consistently “win” over addon versions (a limitation of how Babel + app merging interact).
0reactions
bmaehrcommented, Jun 30, 2021

With that in mind, I’ve changed my code to read like this:

import Trigger from 'ember-power-select/components/power-select/trigger';
export default class extends Trigger { }

And now my custom template is being used!

As a separate issue I cannot seem to find the magical incantation to get TypeScript to allow the import. TypeScript insists on adding /addon/, which fails run time. This might be due to the following caveat listed in ember-cli-typescript:

  • Similarly, apps must use .js to override addon defaults in app , since the different file extension means apps no long consistently “win” over addon versions (a limitation of how Babel + app merging interact).

Could you please explain more precisely (names of the files, what you did else) because I’m also not able to get it working…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Methods to Override Trigger Templates - erwin, Inc.
Use one of the following methods to override the default trigger template: RI Type Override Template. For each referential integrity rule combination, ...
Read more >
Create a Relationship Override Trigger Template
Trigger Template Override. Displays the name of the user override trigger template that you want to generate for the corresponding referential integrity type....
Read more >
Triggers in default Template override styles or property values
Hi, My understanding is, that triggers in the default template of a control override the values of properties and even other triggers which ......
Read more >
How to override general style with trigger in ControlTemplate?
Set the TextBlock.Foreground property of the ContentPresenter : <Setter Property="Template"> <Setter.Value> <ControlTemplate ...
Read more >
override triggers of template_linux for a given host group
I use the standard zabbix template_linux for monitoring disk usage and so on... In the template_linux the trigger for free diskspace in /home...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found