Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(material/dialog): add documentation for MAT_DIALOG_DEFAULT_OPTIONS #20631

Open
Davitigs opened this issue Sep 22, 2020 · 6 comments
Open
Labels
area: material/dialog docs This issue is related to documentation help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@Davitigs
Copy link

Reproduction

Steps to reproduce:

  1. provide MAT_DIALOG_DEFAULT_OPTIONS in the module
  2. provide useValue. (ex. disableClose: true - see the following code)
    {
    provide: MAT_DIALOG_DEFAULT_OPTIONS,
    useValue: {
    disableClose: true,
    },
    },

Expected Behavior

What behavior were you expecting to see?

Configs should be set along with the default values for the other options. Such behaviour can be seen when provided in the component with dialog.open() method

Actual Behavior

What behavior did you actually see?

Given configs overwrite the Configs value, so that default options are also overwritten.

Environment

  • Angular:
  • CDK/Material:
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):
@Davitigs Davitigs added the needs triage This issue needs to be triaged by the team label Sep 22, 2020
@mmalerba mmalerba added cannot reproduce The team is unable to reproduce this issue with the information provided and removed needs triage This issue needs to be triaged by the team labels Sep 22, 2020
@mmalerba
Copy link
Contributor

This seems to be working, here's a stackblitz showing it: https://stackblitz.com/edit/angular-dxw9c8?file=src/main.ts

@Davitigs
Copy link
Author

Davitigs commented Sep 23, 2020

This seems to be working, here's a stackblitz showing it: https://stackblitz.com/edit/angular-dxw9c8?file=src/main.ts

Please try to click on "Open Dialog" button when your popup is already opened:

  1. There is no backdrop
  2. You can open the same popup over and over again without closing the previous one.
    However we both know that by default the backdrop is set to true and in this case there is no backdrop.
@mmalerba
Copy link
Contributor

There is no automatic merging of your override with the default options. If you want to keep the rest of the default options just merge them when providing the value:

{ 
    ...new MatDialogConfig(),
    disableClose: true,
}

See: https://stackblitz.com/edit/angular-dxw9c8-2sxvwj?file=src%2Fmain.ts

@Davitigs
Copy link
Author

why then such automatic merging is happening when the configs are provided in the .open() method?

@mmalerba
Copy link
Contributor

When you call open with a config it merges the given config with the default config. In your case you're overriding the default config, so it merges that with your custom default: {disableClose: true}

@Davitigs
Copy link
Author

I understand that, however in the official documentation there is no info provided for the case when the custom config is provided in the module, you can figure that out only when investigating the source code, I think would be better to somehow include that aspect, it is not intuitive.

@mmalerba mmalerba changed the title bug(COMPONENT): TITLE Sep 23, 2020
@mmalerba mmalerba added docs This issue is related to documentation help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/dialog and removed cannot reproduce The team is unable to reproduce this issue with the information provided labels Sep 23, 2020
@mmalerba mmalerba reopened this Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/dialog docs This issue is related to documentation help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
2 participants