Skip to content

bug(Dialog): restoreFocus in DialogConfig typed wrong #32875

@CSchulz

Description

@CSchulz

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

Type declaration differs from documentation.

restoreFocus should allow boolean, string or HTMLElement, but does only allow boolean values.

If you use any to overwrite the type check it works with string and HTMLElement.

https://material.angular.dev/cdk/dialog/overview#focus-restoration

* Whether the dialog should restore focus to the
* previously-focused element, after it's closed.
*/
restoreFocus?: boolean = true;

Reproduction

Steps to reproduce:

  1. Inject MatDialog
  2. Try using matDialog.open(ref, { restoreFocus: 'some-selector' })

Expected Behavior

Should work with boolean, string or HTMLElement.

Actual Behavior

Expect only boolean.

Environment

Angular CLI       : 21.1.4
Angular           : 21.1.4
Node.js           : 20.19.5
Package Manager   : npm 10.8.2
Operating System  : win32 x64

┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package                           │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations               │ 21.1.4            │ ~21.1.4           │
│ @angular/aria                     │ 21.1.4            │ ~21.1.4           │
│ @angular/build                    │ 21.1.4            │ ~21.1.4           │
│ @angular/cdk                      │ 21.1.4            │ ~21.1.4           │
│ @angular/cli                      │ 21.1.4            │ ~21.1.4           │
│ @angular/common                   │ 21.1.4            │ ~21.1.4           │
│ @angular/compiler                 │ 21.1.4            │ ~21.1.4           │
│ @angular/compiler-cli             │ 21.1.4            │ ~21.1.4           │
│ @angular/core                     │ 21.1.4            │ ~21.1.4           │
│ @angular/forms                    │ 21.1.4            │ ~21.1.4           │
│ @angular/material                 │ 21.1.4            │ ~21.1.4           │
│ @angular/platform-browser         │ 21.1.4            │ ~21.1.4           │
│ @angular/platform-browser-dynamic │ 21.1.4            │ ~21.1.4           │
│ @angular/router                   │ 21.1.4            │ ~21.1.4           │
│ rxjs                              │ 7.8.2             │ ~7.8.2            │
│ typescript                        │ 5.9.3             │ ~5.9.3            │
│ zone.js                           │ 0.15.1            │ ~0.15.0           │
└───────────────────────────────────┴───────────────────┴───────────────────┘

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/bottom-sheetarea: material/dialog

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions