diff --git a/CHANGELOG.md b/CHANGELOG.md index 5548b32285..b0bd72c20a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - CSS styling options to `mwc-tab` - `active` attribute to `mwc-tab` when (de)activated - Added custom properties to style `mwc-checkbox`'s colors +- Added `show` and `close` methods to `mwc-dialog` ### Fixed diff --git a/packages/dialog/README.md b/packages/dialog/README.md index 44ffc7c7ed..37f75be808 100644 --- a/packages/dialog/README.md +++ b/packages/dialog/README.md @@ -232,7 +232,9 @@ npm install @material/mwc-dialog | -------- | ------------- | `forceLayout() => void` | Forces dialog to relayout (animation frame time). May be required if dialog size is incorrect or if stacked layout has not been triggered correctly. | `focus() => void` | Focuses on the initial focus element if defined (see [focus section](#focus)). -| `blur() => void` | Blurs the active element. +| `blur() => void` | Blurs the active element. +| `show() => void` | Opens the dialog. +| `close() => void` | Closes the dialog. ### Listeners | Event Name | Target | Description diff --git a/packages/dialog/src/mwc-dialog-base.ts b/packages/dialog/src/mwc-dialog-base.ts index d7f7dcea6a..040d8081d8 100644 --- a/packages/dialog/src/mwc-dialog-base.ts +++ b/packages/dialog/src/mwc-dialog-base.ts @@ -388,4 +388,12 @@ export class DialogBase extends BaseElement { 'keydown', this.boundHandleDocumentKeydown); } } + + close() { + this.open = false; + } + + show() { + this.open = true; + } }