angular / angular/components

feat(inputs): Add `[readonly]` property to input components

Open
#27,955 9 comments 16 reactions 0 assignees View on GitHub
feature P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### Feature Description

Right now input components (checkbox, chips, datepicker, form field, radio button, select, slider) have `[disabled]` property. Only `matInput` directive has `[readonly]`.

`[disabled]` property conflicts with the `[formControl]` directive, which has a [property with the same name](https://github.com/angular/angular/blob/main/packages/forms/src/directives/reactive_directives/form_control_directive.ts#L72).

So if you use `[formControl]` with the components listed above, it is not possible to use their `[disabled]` property.

### Use Case

`[disabled]` controls [will not be included](https://github.com/angular/angular/blob/main/packages/forms/src/model/abstract_model.ts#L409) in `form.value` - sometimes you need to render an input element as read-only but still send its value to the server.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the existing [readonly] behavior on the matInput directive with the checkbox, chips, datepicker, form field, radio button, select, and slider components. Read the linked FormControlDirective property and AbstractControl documentation to understand the disabled/value interaction. Done means each listed component supports [readonly] without excluding its value from form.value.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.