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

fix(dialog): close via v-model #380

Merged
merged 3 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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