mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-10 09:22:34 +00:00
Fixed #2662 - Add after-hide event to Dialog
This commit is contained in:
parent
6e608144b9
commit
a3848aa6d3
4 changed files with 36 additions and 19 deletions
|
@ -138,6 +138,10 @@ const DialogEvents = [
|
||||||
name: "hide",
|
name: "hide",
|
||||||
description: "Callback to invoke when dialog is hidden."
|
description: "Callback to invoke when dialog is hidden."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "after-hide",
|
||||||
|
description: "Callback to invoke after dialog is hidden."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "show",
|
name: "show",
|
||||||
description: "Callback to invoke when dialog is showed."
|
description: "Callback to invoke when dialog is showed."
|
||||||
|
|
12
src/components/dialog/Dialog.d.ts
vendored
12
src/components/dialog/Dialog.d.ts
vendored
|
@ -154,11 +154,15 @@ export declare type DialogEmits = {
|
||||||
/**
|
/**
|
||||||
* Callback to invoke when dialog is hidden.
|
* Callback to invoke when dialog is hidden.
|
||||||
*/
|
*/
|
||||||
'show': () => void;
|
|
||||||
/**
|
|
||||||
* Callback to invoke when dialog is showed.
|
|
||||||
*/
|
|
||||||
'hide': () => void;
|
'hide': () => void;
|
||||||
|
/**
|
||||||
|
* Callback to invoke after dialog is hidden.
|
||||||
|
*/
|
||||||
|
'after-hide': () => void;
|
||||||
|
/**
|
||||||
|
* Callback to invoke when dialog is shown.
|
||||||
|
*/
|
||||||
|
'show': () => void;
|
||||||
/**
|
/**
|
||||||
* Fired when a dialog gets maximized.
|
* Fired when a dialog gets maximized.
|
||||||
* @param {event} event - Browser event.
|
* @param {event} event - Browser event.
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { computed } from 'vue';
|
||||||
import { UniqueComponentId,DomHandler,ZIndexUtils } from 'primevue/utils';
|
import { UniqueComponentId,DomHandler,ZIndexUtils } from 'primevue/utils';
|
||||||
import Ripple from 'primevue/ripple';
|
import Ripple from 'primevue/ripple';
|
||||||
import Portal from 'primevue/portal';
|
import Portal from 'primevue/portal';
|
||||||
|
@ -36,7 +37,7 @@ import Portal from 'primevue/portal';
|
||||||
export default {
|
export default {
|
||||||
name: 'Dialog',
|
name: 'Dialog',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
emits: ['update:visible','show','hide','maximize','unmaximize','dragend'],
|
emits: ['update:visible','show','hide', 'after-hide', 'maximize','unmaximize','dragend'],
|
||||||
props: {
|
props: {
|
||||||
header: null,
|
header: null,
|
||||||
footer: null,
|
footer: null,
|
||||||
|
@ -98,6 +99,12 @@ export default {
|
||||||
appendTo: {
|
appendTo: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'body'
|
default: 'body'
|
||||||
|
},
|
||||||
|
_instance: null
|
||||||
|
},
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
dialogRef: computed(() => this._instance)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -125,12 +132,11 @@ export default {
|
||||||
this.unbindGlobalListeners();
|
this.unbindGlobalListeners();
|
||||||
this.destroyStyle();
|
this.destroyStyle();
|
||||||
|
|
||||||
this.mask = null;
|
if (this.mask && this.autoZIndex) {
|
||||||
|
ZIndexUtils.clear(this.mask);
|
||||||
if (this.container && this.autoZIndex) {
|
|
||||||
ZIndexUtils.clear(this.container);
|
|
||||||
}
|
}
|
||||||
this.container = null;
|
this.container = null;
|
||||||
|
this.mask = null;
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.breakpoints) {
|
if (this.breakpoints) {
|
||||||
|
@ -142,19 +148,17 @@ export default {
|
||||||
this.$emit('update:visible', false);
|
this.$emit('update:visible', false);
|
||||||
},
|
},
|
||||||
onBeforeEnter(el) {
|
onBeforeEnter(el) {
|
||||||
if (this.autoZIndex) {
|
|
||||||
ZIndexUtils.set('modal', el, this.baseZIndex + this.$primevue.config.zIndex.modal);
|
|
||||||
}
|
|
||||||
|
|
||||||
el.setAttribute(this.attributeSelector, '');
|
el.setAttribute(this.attributeSelector, '');
|
||||||
},
|
},
|
||||||
onEnter() {
|
onEnter() {
|
||||||
this.mask.style.zIndex = String(parseInt(this.container.style.zIndex, 10) - 1);
|
|
||||||
|
|
||||||
this.$emit('show');
|
this.$emit('show');
|
||||||
this.focus();
|
this.focus();
|
||||||
this.enableDocumentSettings();
|
this.enableDocumentSettings();
|
||||||
this.bindGlobalListeners();
|
this.bindGlobalListeners();
|
||||||
|
|
||||||
|
if (this.autoZIndex) {
|
||||||
|
ZIndexUtils.set('modal', this.mask, this.baseZIndex + this.$primevue.config.zIndex.modal);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onBeforeLeave() {
|
onBeforeLeave() {
|
||||||
if (this.modal) {
|
if (this.modal) {
|
||||||
|
@ -162,16 +166,16 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLeave() {
|
onLeave() {
|
||||||
|
|
||||||
this.$emit('hide');
|
this.$emit('hide');
|
||||||
},
|
},
|
||||||
onAfterLeave(el) {
|
onAfterLeave() {
|
||||||
if (this.autoZIndex) {
|
if (this.autoZIndex) {
|
||||||
ZIndexUtils.clear(el);
|
ZIndexUtils.clear(this.mask);
|
||||||
}
|
}
|
||||||
this.containerVisible = false;
|
this.containerVisible = false;
|
||||||
this.unbindDocumentState();
|
this.unbindDocumentState();
|
||||||
this.unbindGlobalListeners();
|
this.unbindGlobalListeners();
|
||||||
|
this.$emit('after-hide');
|
||||||
},
|
},
|
||||||
onMaskClick(event) {
|
onMaskClick(event) {
|
||||||
if (this.dismissableMask && this.closable && this.modal && this.mask === event.target) {
|
if (this.dismissableMask && this.closable && this.modal && this.mask === event.target) {
|
||||||
|
|
|
@ -254,6 +254,11 @@ export default {
|
||||||
<td>-</td>
|
<td>-</td>
|
||||||
<td>Callback to invoke when dialog is hidden.</td>
|
<td>Callback to invoke when dialog is hidden.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>after-hide</td>
|
||||||
|
<td>-</td>
|
||||||
|
<td>Callback to invoke after dialog is hidden.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>show</td>
|
<td>show</td>
|
||||||
<td>-</td>
|
<td>-</td>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue