angular / angular/angular

Custom directive implementing controlValueAccessor does not trigger writeValue if the formControl has been updated by another controlValueAccessor

Aberta
#43,484 4 comentários 17 reações 0 responsáveis Ver no GitHub
area: forms P3
Linguagem predominante
TypeScript
Estrelas
101k
Forks
27.5k
Merge médio
1d 20h
PRs com merge (30d)
299

Descrição

### Which @angular/* package(s) are the source of the bug?

forms

### Is this a regression?

No

### Description

I've created a custom directive implementing controlValueAccessor and added it to two html input elements.

The writeValue function is not called if the input value is provided using [formControl] and the value is updated through the registerOnChange callback.

The writeValue is instead correctly called if the input value is provided by [(ngModel)] instead of [formControl]

```
Export class customDirective implements controlValueAccessor ...

With ngModel works fine

With formControl there's the issue

```

### Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-a2loir?file=src%2Fapp%2Fapp.component.html

### Please provide the exception or error you saw

_No response_

### Please provide the environment you discovered this bug in

_No response_

### Anything else?

_No response_

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Comece pela reprodução vinculada do StackBlitz e pela implementação de ControlValueAccessor em @angular/forms, comparando os caminhos de binding de [formControl] e [(ngModel)]. Rastreie as chamadas de registerOnChange e writeValue para dois controles que compartilham o mesmo valor e, em seguida, adicione ou atualize a cobertura para que a reprodução se comporte de forma consistente e writeValue seja chamado quando o controle do formulário mudar.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
angular, typescript
Domínio
frontend
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
42/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.