Fixed #3535 - Sidebar: transition class update and adding after-hide event
parent
48213f4d0e
commit
102c5c13a8
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<Portal>
|
<Portal>
|
||||||
<div v-if="maskVisible" ref="mask" style="maskStyle" :class="maskClasses" @mousedown="onMaskClick">
|
<div v-if="containerVisible" :ref="maskRef" :class="maskClass" @mousedown="onMaskClick">
|
||||||
<transition name="p-sidebar" @after-enter="onAfterEnter" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave" appear>
|
<transition name="p-sidebar" @enter="onEnter" @before-leave="onBeforeLeave" @leave="onLeave" @after-leave="onAfterLeave" appear>
|
||||||
<div v-if="visible" :ref="containerRef" v-focustrap :class="containerClass" role="complementary" :aria-modal="modal" @keydown="onKeydown" v-bind="$attrs">
|
<div v-if="visible" :ref="containerRef" v-focustrap :class="containerClass" role="complementary" :aria-modal="modal" @keydown="onKeydown" v-bind="$attrs">
|
||||||
<div :ref="headerContainerRef" class="p-sidebar-header">
|
<div :ref="headerContainerRef" class="p-sidebar-header">
|
||||||
<div v-if="$slots.header" class="p-sidebar-header-content">
|
<div v-if="$slots.header" class="p-sidebar-header-content">
|
||||||
|
@ -29,7 +29,7 @@ import { DomHandler, ZIndexUtils } from 'primevue/utils';
|
||||||
export default {
|
export default {
|
||||||
name: 'Sidebar',
|
name: 'Sidebar',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
emits: ['update:visible', 'show', 'hide'],
|
emits: ['update:visible', 'show', 'hide', 'after-hide'],
|
||||||
props: {
|
props: {
|
||||||
visible: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -69,18 +69,19 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
container: null,
|
container: null,
|
||||||
|
mask: null,
|
||||||
content: null,
|
content: null,
|
||||||
headerContainer: null,
|
headerContainer: null,
|
||||||
closeButton: null,
|
closeButton: null,
|
||||||
outsideClickListener: null,
|
outsideClickListener: null,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
maskVisible: false
|
containerVisible: this.visible
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
updated() {
|
||||||
visible(newValue) {
|
if (this.visible) {
|
||||||
this.maskVisible = newValue ? newValue : this.maskVisible;
|
this.containerVisible = this.visible;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
|
@ -100,17 +101,21 @@ export default {
|
||||||
},
|
},
|
||||||
onEnter() {
|
onEnter() {
|
||||||
this.$emit('show');
|
this.$emit('show');
|
||||||
|
this.focus();
|
||||||
|
this.bindOutsideClickListener();
|
||||||
|
|
||||||
if (this.autoZIndex) {
|
if (this.autoZIndex) {
|
||||||
ZIndexUtils.set('modal', this.$refs.mask, this.baseZIndex || this.$primevue.config.zIndex.modal);
|
ZIndexUtils.set('modal', this.mask, this.baseZIndex || this.$primevue.config.zIndex.modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.maskVisible = true;
|
if (this.blockScroll) {
|
||||||
this.focus();
|
DomHandler.addClass(document.body, 'p-overflow-hidden');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onBeforeLeave() {
|
||||||
|
DomHandler.addClass(this.mask, 'p-component-overlay-leave');
|
||||||
},
|
},
|
||||||
onLeave() {
|
onLeave() {
|
||||||
DomHandler.addClass(this.$refs.mask, 'p-component-overlay-leave');
|
|
||||||
|
|
||||||
this.$emit('hide');
|
this.$emit('hide');
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
},
|
},
|
||||||
|
@ -119,13 +124,12 @@ export default {
|
||||||
ZIndexUtils.clear(this.mask);
|
ZIndexUtils.clear(this.mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.maskVisible = false;
|
this.containerVisible = false;
|
||||||
|
this.$emit('after-hide');
|
||||||
},
|
},
|
||||||
onAfterEnter() {
|
onMaskClick(event) {
|
||||||
this.bindOutsideClickListener();
|
if (this.dismissable && this.modal && this.mask === event.target) {
|
||||||
|
this.hide();
|
||||||
if (this.blockScroll) {
|
|
||||||
DomHandler.addClass(document.body, 'p-overflow-hidden');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
focus() {
|
focus() {
|
||||||
|
@ -150,14 +154,12 @@ export default {
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMaskClick(event) {
|
|
||||||
if (this.dismissable && this.modal && this.$refs.mask === event.target) {
|
|
||||||
this.hide();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
containerRef(el) {
|
containerRef(el) {
|
||||||
this.container = el;
|
this.container = el;
|
||||||
},
|
},
|
||||||
|
maskRef(el) {
|
||||||
|
this.mask = el;
|
||||||
|
},
|
||||||
contentRef(el) {
|
contentRef(el) {
|
||||||
this.content = el;
|
this.content = el;
|
||||||
},
|
},
|
||||||
|
@ -211,14 +213,14 @@ export default {
|
||||||
closeAriaLabel() {
|
closeAriaLabel() {
|
||||||
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.close : undefined;
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.close : undefined;
|
||||||
},
|
},
|
||||||
maskClasses() {
|
maskClass() {
|
||||||
return [
|
return [
|
||||||
'p-sidebar-mask',
|
'p-sidebar-mask',
|
||||||
this.getPositionClass(),
|
this.getPositionClass(),
|
||||||
{
|
{
|
||||||
'p-component-overlay p-component-overlay-enter': this.modal,
|
'p-component-overlay p-component-overlay-enter': this.modal,
|
||||||
'p-sidebar-mask-scrollblocker': this.blockScroll,
|
'p-sidebar-mask-scrollblocker': this.blockScroll,
|
||||||
'p-sidebar-visible': this.maskVisible,
|
'p-sidebar-visible': this.containerVisible,
|
||||||
'p-sidebar-full': this.fullScreen
|
'p-sidebar-full': this.fullScreen
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -249,14 +251,14 @@ export default {
|
||||||
transition-property: background-color;
|
transition-property: background-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-sidebar-visible {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-sidebar-mask.p-component-overlay {
|
.p-sidebar-mask.p-component-overlay {
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.p-sidebar-visible {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
.p-sidebar {
|
.p-sidebar {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -391,14 +393,6 @@ export default {
|
||||||
height: 30rem;
|
height: 30rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-sidebar-left .p-sidebar-view,
|
|
||||||
.p-sidebar-right .p-sidebar-view,
|
|
||||||
.p-sidebar-top .p-sidebar-view,
|
|
||||||
.p-sidebar-bottom .p-sidebar-view {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-sidebar-left .p-sidebar-content,
|
.p-sidebar-left .p-sidebar-content,
|
||||||
.p-sidebar-right .p-sidebar-content,
|
.p-sidebar-right .p-sidebar-content,
|
||||||
.p-sidebar-top .p-sidebar-content,
|
.p-sidebar-top .p-sidebar-content,
|
||||||
|
|
|
@ -147,6 +147,11 @@ import Sidebar from 'primevue/sidebar';
|
||||||
<td>-</td>
|
<td>-</td>
|
||||||
<td>Callback to invoke when sidebar gets hidden.</td>
|
<td>Callback to invoke when sidebar gets 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>
|
||||||
|
@ -210,7 +215,7 @@ import Sidebar from 'primevue/sidebar';
|
||||||
<td>Container element of a full screen sidebar.</td>
|
<td>Container element of a full screen sidebar.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>p-sidebar-active</td>
|
<td>p-sidebar-visible</td>
|
||||||
<td>Container element when sidebar is visible.</td>
|
<td>Container element when sidebar is visible.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue