Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
fix(dialog): close via v-model (#380)
Browse files Browse the repository at this point in the history
fixes #376

add documents
  • Loading branch information
tychenjiajun authored Aug 12, 2019
1 parent 3055acd commit 13895fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/dialog/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default {
},
watch: {
open () {
if (this.open) this.mdcDialog.open()
this.open ? this.mdcDialog.open() : this.mdcDialog.close()
},
stacked () {
this.mdcDialog.autoStackButtons = this.stacked
Expand Down Expand Up @@ -176,6 +176,7 @@ export default {
}
})
}
this.mdcDialog.layout()
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions components/dialog/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Dialog

[Codepen example](https://codepen.io/chankcccc/pen/aeYpBJ)

### Markup

```html
Expand All @@ -25,6 +27,7 @@
```

### Script

```javascript
data () {
return {
Expand All @@ -38,6 +41,8 @@ methods: {
}
```

Close via setting `isDialogOpen` to false will emit `closing` and `closed` event without the `action` value in its payload.

### Props

| Prop | Type | Default | Description |
Expand All @@ -56,8 +61,11 @@ methods: {
|-------|---------|-------------|
| opening | {} | emitted when dialog is opening |
| opened | {} | emitted when dialog is opened |
| closing | { action: value } | emitted when dialog is closing |
| closed | { action: value } | emitted when dialog is closed |
| closing | { action?: value } | emitted when dialog is closing |
| closed | { action?: value } | emitted when dialog is closed |

The complete order of events emitted in the open and close process is `opening`, `opened`, `closing`, `change` and `closed`


### Slots

Expand All @@ -70,6 +78,10 @@ methods: {
| cancelButton | cancel button |
| dialogButton | additional button(s) |

### Accessibility Concerns

Dialog should have at least one focusable element, e.g. buttons in dialogButton slots. For providing messages, use `<m-snackbar>` instead.

### Reference

- https://github.com/material-components/material-components-web/tree/master/packages/mdc-dialog

0 comments on commit 13895fc

Please sign in to comment.