Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Feature (MatDialog): Add an option to prevent duplicate dialogs

Aberta
#34,005 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
angular, typescript
Domínio
frontend

Direção de pesquisa

Start by reading the MatDialog API and its existing openDialogs and getDialogById() behavior. The proposal leaves key behavior undecided, including whether to return the existing reference or ignore the request, and how duplicate detection should be customized. Done criteria would need maintainers to settle those choices and define how component type matching works.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

area: material/dialog feature gemini-triaged needs triage
Feature Description

Currently, Angular Material’s MatDialog allows the same component to be opened multiple times, resulting in multiple instances of the same dialog being displayed simultaneously.

In some applications, this behavior is undesirable. For example, repeated user interactions or multiple event emissions can accidentally open the same dialog more than once.

Developers must currently implement their own duplicate detection logic using MatDialog.openDialogs or MatDialog.getDialogById() before calling MatDialog.open().

Proposed solution

It would be useful to have a built-in option in MatDialogConfig to prevent duplicate instances of the same component from being opened.

For example:

this.dialog.open(MyDialogComponent, {
preventDuplicates: true,
});

When this option is enabled, attempting to open a component that already has an open dialog could either:

  • Return the existing MatDialogRef without creating another instance.
  • Ignore the new request and keep the existing dialog open.

The exact behavior could be determined by the maintainers.

Ideally, duplicate detection would be scoped to the component type, with an option to customize the behavior if needed.

Benefits

  • Avoids accidentally opening multiple instances of the same dialog.
  • Reduces repetitive boilerplate across applications.
  • Provides a consistent, framework-level solution.
  • Keeps applications simpler and less error-prone.

Alternatives considered

Currently, developers can manually inspect openDialogs or use getDialogById() before opening a dialog. However, this requires additional application-level logic and does not provide a straightforward, reusable option for this common use case.

Would this feature be a good fit for Angular Material’s MatDialog API? I’d be happy to contribute a PR if the maintainers consider this approach appropriate.

Use Case

No response

Linguagem predominante
TypeScript
Estrelas
25k
Forks
6.8k
Merge médio
3d 1h
PRs com merge (30d)
69

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de angular/components

Todas as issues de angular/components

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.