bug: Two-way binding broken between Angular template-driven forms and Stencil
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- angular, typescript
- Domain
- frontend
Research direction
Start with the Stencil-generated Angular value accessor from @stencil/angular-output-target and reproduce the issue using Angular FormsModule, ngModel, and a form-associated component with a value property. Compare behavior between Stencil 4.35.3 and 4.36.0, focusing on the writeValue path. Done means template-driven forms update the web component's host value consistently with reactive forms.
Written by the indexing model from the issue text.
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Stencil Version
4.36.0-current
Current Behavior
When using Stencil’s Angular value accessor, the writeValue method is invoked as expected and receives the correct value from the Angular form. However, the underlying logic responsible for applying this value to the Stencil web component (i.e., writing to the host component’s value property) does not appear to execute correctly. As a result, the value is not actually set on the host component. This issue only occurs when using Angular Template-driven forms; Reactive forms continue to function as expected. This behavior appears to be a regression introduced in Stencil v4.36.0 and later versions, as the same setup works correctly in v4.35.3.
Expected Behavior
When using Stencil’s Angular value accessor with template-driven forms, the value provided by Angular (via ngModel) should be correctly propagated through the writeValue method and applied to the Stencil web component by updating the host component’s value property. The component should remain fully synchronized with the form state, behaving consistently with reactive forms and with prior Stencil versions (e.g. v4.35.3), where this integration worked as expected.
System Info
Platform: windows (10.0.26100)
CPU Model: Intel Xeon Processor (Icelake) (4 cpus)
Compiler: C:\dev\projects\design-system\node_modules\@stencil\core\compiler\stencil.js
Build: 1752598220
Stencil: 4.36.0
TypeScript: 5.5.4
Rollup: 4.34.9
Parse5: 7.2.1
jQuery: 4.0.0-pre
Terser: 5.37.0
Steps to Reproduce
- Create a form-associated Stencil web component (using
ElementInternals) that exposes avalueproperty (e.g. a text input–like component). - Enable Angular support for the component and use the Stencil-generated Angular value accessor for a text-type value.
- Build the Stencil component and include it in an Angular application.
- In Angular, create a template-driven form using
FormsModule. - Use the Stencil web component inside the template-driven form and bind it with
ngModel, for example:
<my-text-field [(ngModel)]="modelValue" name="field"></my-text-field>
- Initialize or update
modelValuefrom the Angular component class. - Observe that the Angular value accessor’s
writeValuemethod is called with the correct value. - Observe that the value is not written to the Stencil web component’s host element (the component’s
valueproperty is not updated) - using lifecycle hooks also doesn't seem to do the job as the value is not even received in any of them.
Code Reproduction URL
to-be-added
Additional Information
- I've tested the subsequent versions since
v4.35.3and they all seem to suffer from the same issue; - Used
@stencil/[email protected]to generate all Angular related code - also tested with later versions, the issue seems to persist.
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 870
- Avg merge
- 2d 54m
- Merged PRs (30d)
- 50
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 stenciljs/core
-
bug: v5 dist/types/components.d.ts imports @stencil/core/runtime instead of ./stencil-public-runtimeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Stencil FOUC styles should use @layer to avoid cascade conflicts with React 19Possibly taken @johnjenkins claimed this 241 days ago. OpenStencil v5
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug: v5 streamed SSR host is released too early when a script inserts a node while it is parsedOpen
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
feat: write reflected attributes when the prop changes, not on the next renderPossibly taken @johnjenkins claimed this 241 days ago. OpenStencil v5
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
superlinked/sie#1033 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
remix-run/react-router#15838 ·
Maintainers usually reply within 1 day
-
area/ci bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
melgarafael/DeskcommCRM#5290 ·
Maintainers usually reply within 1 day