bug(mat-select): mat-options not showing up on dynamically generated component
@andrewseguin y travaille déjà.
Depuis le 11/8/2025.
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 91
Description
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
Hi, this is my first issue, so I hope everything is corrent.
I'm currently implementing some map popups (using leaflet, but I assume the issue would also appear for other map providers) in my app, using dynamically generated components as their content. Within that components, I have a mat-select, which is not displaying any options, as the title mentioned. When I click on it, the select field itself is focused and gets the correct classes, but the options overlay is not appearing.
My guess is, that something is wrong with the handling of the overlay in combination with dynamically generated components. When checking the DOM, I could see that the overlay container was not added to the body. Outside of the dynamic component the exact same mat-select works as expected. I also tried to create a dialog within my dynamic component and it also works fine (overlay container is attached to the body).
Every other functionality within the component is working as well (root services, ngrx store, ...).
There are no console errors.
Module imports contain MatSelectModule, MatInputModule & MatFormFieldModule.
Is this a bug or am I just missing something?
Reproduction
- add mat-select to popupComponent:
<mat-form-field appearance="fill">
<mat-select multiple [formControl]="statusFormControl">
<mat-option *ngFor="let status of statuses" [value]="status">{{ status.id }}</mat-option>
</mat-select>
</mat-form-field>
- Generate Component with createComponent(), using a generic EnvironmentInjector:
const popupComponent: ComponentRef<PopupComponent> = createComponent(PopupComponent, {
environmentInjector: this._environmentInjector
});
- Add data to the component and execute change detection:
component.instance.statuses = statuses;
component.changeDetectorRef.detectChanges();
- bind content to map popup (might be a possible source for the bug as well):
mapMarker.bindPopup(popupComponent.location.nativeElement as Content);
- when opening the popup on the map and clicking on the select, the highlighting is correct, but nothing else happens:

Expected Behavior
mat-options should show up
Actual Behavior
mat-options notshowing up, overlay container not attached
Environment
- Angular: 15.0.2
- CDK/Material: 15.1.4
- Browser(s): Firefox 102.8
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Évaluation
Cette issue n'a pas encore été évaluée.