Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

bug(mat-checkbox): with Signal Forms `required()`, MatCheckbox's own validator adds a duplicate `required` error that hides the schema error message

Aberta
#33,945 1 comentário 1 reação 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

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

Direção de pesquisa

Start by tracing how Signal Forms errors are combined with the MatCheckbox validator; the issue names MatCheckbox.validate() and CompatValidationError but does not identify source files or tests. Reproduce with the linked StackBlitz and inspect the error output. Done means the field exposes only the schema’s required error, including its custom message.

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

Descrição

area: material/checkbox P3
Is this a regression?
  • Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was

No response

Description

When a mat-checkbox is bound to a Signal Forms field with [formField] and the schema uses required(), the field ends up with two errors of kind required:

  1. the schema error from required(path, { message }) - has the custom message;
  2. a CompatValidationError (kind required, no message) produced by MatCheckbox.validate().

This happens with many components which have 'required' input and validate method from Validators interface.

Reproduction

StackBlitz link: https://stackblitz.com/edit/1sinlau9-qd7bhr37?file=src%2Fexample%2Fcheckbox-signal-forms-example.ts
Steps to reproduce:

  1. Open the console
  2. Click the 'Show errors' button. The first getError('required) log shows kind: required and message: undefined. The second errors() log shows 2 errors.

As the result nothing is rendered

Expected Behavior
  • The field has a single required error, the one from the schema.
Actual Behavior
  • errors() contains two required errors: first a CompatValidationError from MatCheckbox.validate() (message is undefined), then the schema error.
  • getError('required') returns the first one, so getError('required')?.message is undefined and nothing is rendered.
Environment
  • Angular: 22.0.6
  • CDK/Material: 22.0.4
  • Browser(s): Google Chrome Version 154.0.8037.98
  • Operating System: MacOs 27.0
Linguagem predominante
TypeScript
Estrelas
25k
Forks
6.8k
Merge médio
1d 4h
PRs com merge (30d)
69

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de angular/components

Todas as issues de angular/components

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

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