bug(MatInput): read-only inputs are not considered focused
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 91
Description
#### Reproduction
[StackBlitz](https://stackblitz.com/edit/focused-readonly-input-bug)
Steps to reproduce:
1. Use the toggle to place the input in a read-only state
2. Tab to or click on the input to give it focus
3. Observe that the input has focus, but `MatInput` does not report it as focused
#### Expected Behavior
According to the Material [Text fields spec -> Read-only fields](https://material.io/components/text-fields#input-types)
>A read-only text field is styled the same as a regular text field.
Read-only inputs should receive the same focus styles as regular inputs. The `MatFormField` component conditionally applies focus styles (`mat-focused` class) based on the `focused` property of the `MatInput`.
https://github.com/angular/components/blob/master/src/material/form-field/form-field.ts#L139
When a read-only input is focused, `MatInput` should report it as focused to ensure focus styles are applied correctly.
#### Actual Behavior
`MatInput` filters out focus events on read-only inputs, always reporting them as not focused.
https://github.com/angular/components/blob/master/src/material/input/input.ts#L344
This results in the `mat-focused` class never being applied to `MatFormField`'s that wrap read-only inputs.
#### Environment
- Angular: 10.2.3
- CDK/Material: 10.2.7
- Browser(s): N/A
- Operating System (e.g. Windows, macOS, Ubuntu): N/A
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Reproduisez le comportement à l’aide du StackBlitz fourni, puis examinez src/material/input/input.ts autour de la ligne 344 et src/material/form-field/form-field.ts autour de la ligne 139. Confirmez que la mise au point d’un input en lecture seule est signalée et que le MatFormField environnant reçoit la classe mat-focused ainsi que les styles de focus correspondants.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- frontend
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100