material-components / material-components/material-web

md-select-option selected not getting selected on angular reactive form

Open
#5,590 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
11.3k
Forks
1.1k
Avg merge
20h 28m
Merged PRs (30d)
13

Description

### What is affected?

Component

### Description

When I try to use md-outlined-select with Reactive Forms on Angular 17

### Reproduction

In Angular, I have a form with Reactive Forms, it has a couple of Inputs, Selects, and a Submit button to perform a search. When navigating to another route and returning to my search page, the input fields do show the previously entered values, but this does not happen with the Selects.

However, if I use the Selects with ngModel using Template-driven forms, all the select fields work correctly.

Selects doesn't works with Reactive Forms on Angular 17.x:






Deporte


@for (sport of (sports$ | async); track sport.id) {

{{ sport.name }}


}

### Workaround

Using Template-drive Forms works:



Deporte


@for (sport of (sports$ | async); track sport.id) {

{{ sport.name }}


}

### Is this a regression?

No or unsure. This never worked, or I haven't tried before.

### Affected versions

@material/web@1.4.x / and nightly

### Browser/OS/Node environment

Brave Version 1.64.122 Chromium: 123.0.6312.122 (Official Build) (64-bit)
Chrome / Firefox on Arch Linux 6.8

Node 18.18.2
Angular 17.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Angular 17 reactive-forms example with md-outlined-select and compare it with the provided template-driven workaround. Trace how formControlName values are applied when the route is revisited. Done means the select retains its previously entered value with Reactive Forms, while the existing inputs and template-driven workaround continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular
Domain
frontend
Issue type
Bug
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.