-
Notifications
You must be signed in to change notification settings - Fork 6.8k
bug(timepicker): Multiple overlays and host already has a portal attached #30637
Copy link
Copy link
Closed
Closed
Copy link
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/timepicker
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
Clicking outside a Timepicker enclosed by a MatFormField causes an error and multiple Timepicker overlays.
ERROR Error: Host already has a portal attached
at throwPortalAlreadyAttachedError (portal.mjs:17:9)
at DomPortalOutlet.attach (portal.mjs:196:9)
at OverlayRef.attach
Reproduction
Error "Host already has a portal attached"
StackBlitz link: https://stackblitz.com/edit/components-issue-starter-v6k1y4ci?file=src%2Fmain.ts
Steps to reproduce:
- Open StackBlitz link
- Click into the
Timepickerinput (overlay should open upwards) - Click right below the
Timepicker. Just right below theMatFormFieldwhere hints and errors (would) appear - Look at the browser console output
Multiple overlays
Steps to reproduce:
- Head to https://material.angular.io/components/timepicker/examples
- Scroll so that a timepicker is at the bottom of the browser window, which should cause the timepicker overlay to open upwards.
- Click into the
Timepickerinput (overlay should open upwards) - Click right below the
Timepicker. Just right below theMatFormFieldwhere hints and errors (would) appear - Now there should be two
Timepickeroverlays - Repeat step 4 as often as you like to create N overlays
(no idea how to reproduce this behavior in StackBlitz/local)
Code for reproduction
@Component({
selector: 'app-root',
standalone: true,
imports: [DemoMaterialModule],
template: `
<mat-form-field>
<mat-label>Pick a time</mat-label>
<input matInput [matTimepicker]="picker">
<mat-timepicker-toggle matIconSuffix [for]="picker"/>
<mat-timepicker #picker/>
</mat-form-field>
`,
styles: `
:host {
display: flex;
flex-direction: column;
justify-content: flex-end;
height: calc(100vh - 2rem);
}
`
})
export class App {}Expected Behavior
- No error
- No multiple
Timepickeroverlays - The already existing overlay should be closed and not reopened
Actual Behavior
- error "Host already has a portal attached"
- Multiple
Timepickeroverlays (at leat at https://material.angular.io/components/timepicker/examples) - The already existing overlay gets closed and reopened
Environment
- Angular: 19.2.0
- CDK/Material: 19.2.1
- Browser(s): Edge
- Operating System (e.g. Windows, macOS, Ubuntu): Windows
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/timepicker