will-destroy does not invoke re-rendering
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- frontend
Research direction
Start with the supplied integration test for the will-destroy modifier and reproduce the tracked-property update during teardown. Trace the modifier's destruction entry point and compare it with did-insert behavior; done means the test observes “World” immediately after show is set to false, without needing the button click.
Written by the indexing model from the issue text.
Description
This happened when I tried to write a HOC with a parent passing a function to its child, and the function gets called when the child is inserted and going to be destroyed. I made an integration test to demonstrate the issue.
import Component from '@glimmer/component';
import { click, find, render } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { action } from '@ember/object';
import hbs from 'htmlbars-inline-precompile';
import { setupRenderingTest } from 'ember-qunit';
import { tracked } from '@glimmer/tracking';
module('Integration | Modifier | will-destroy', hooks => {
setupRenderingTest(hooks);
test('it should invoke UI re-rendering when changing tracked properties', async function(assert) {
this.owner.register(
'component:parent-component',
class extends Component {
@tracked text = '';
get message() {
return this.text;
}
@action changeText(text) {
this.text = text;
}
}
);
this.owner.register(
'template:components/parent-component',
hbs`
<div data-dummy>{{this.message}}</div>
{{yield (hash changeText=this.changeText)}}
`
);
this.set('show', true);
await render(
hbs`
<ParentComponent as |parent|>
{{#if show}}
<div
{{did-insert (fn parent.changeText "Hello")}}
{{will-destroy (fn parent.changeText "World")}}
>
</div>
{{/if}}
<button data-button {{on "click" (fn parent.changeText "World")}}>Change Text</button>
</ParentComponent>
`
);
// did-insert invokes re-rendering correctly, now the message is "Hello".
assert.strictEqual(find('[data-dummy]').innerText, 'Hello');
// trigger destroying. should change text.
this.set('show', false);
// will-destroy does not invoke re-rendering. message supposed to be "World".
assert.strictEqual(find('[data-dummy]').innerText, 'Hello');
await click('[data-button]');
// if the changeText function is called by other ways, it works seamlessly.
assert.strictEqual(find('[data-dummy]').innerText, 'World');
});
});
Also attached some dependencies info here.
"devDependencies": {
"@ember/optional-features": "^0.7.0",
"@ember/render-modifiers": "^1.0.2",
"@glimmer/component": "^0.14.0-alpha.13",
"ember-cli": "~3.13.1",
"ember-cli-babel": "^7.7.3",
"ember-source": "~3.13.2"
},
- Dominant language
- TypeScript
- Stars
- 86
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from emberjs/ember-render-modifiers
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
emberjs/ember-render-modifiers#38 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
emberjs/ember-render-modifiers#23 · 2 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
emberjs/ember-render-modifiers#21 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
emberjs/ember-render-modifiers#20 · 4 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
emberjs/ember-render-modifiers#17 · 8 comments · 3 reactions ·
All issues in emberjs/ember-render-modifiers
Similar issues
-
Browser Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
getsentry/sentry-javascript#24577 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
agilepathway/label-checker#640 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
agentic-workflows
Difficulty 1/5 Under an hour Newbie friendliness 85/100
githubnext/rig#534 ·
-
automation missing-model model-sync provider:pioneer
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
anomalyco/models.dev#7701 ·