Skip to content

bug(MATDIALOG): MatDialogConfig.id not working #24251

Closed
@diogodomanski

Description

@diogodomanski

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

I'm trying to set custom IDs for MatDialogRef, but it is not working. Any custom ID is being overriden by default strategy (mat-dialog-)

Reproduction

// loading-dialog.service.ts

@Injectable()
export class LoadingDialogService
{
    private _sequence: number = 0;
    constructor(private _dialog: MatDialog) { }

    openDialog() {
        const dialogRef = this._dialog.open(LoadingDialogComponent, {
            id: `loading-dialog-${this._sequence++}`
        });
        console.log(dialogRef.id); // mat-dialog-0 instead of loading-dialog-0
    }
}

Expected Behavior

DialogRef.id should contain the value passed in id property

Actual Behavior

DialogRef.id value seems to be being ignored and overwritten by default strategy

Environment

  • Angular: 13.1.3
  • CDK/Material: 13.1.3
  • Browser(s): Brave 1.34.80
  • Operating System (e.g. Windows, macOS, Ubuntu): Ubuntu 21.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions