Fix Portal isClient detection, fix onBlur method in Calendar - fixes #2689 (#2714)

* Fixed #2689 - fix Portal mounted, fix onBlur method in Calendar

* Fixed #2689 - revert accidentally changed line

Co-authored-by: Alex Popov <al@twentyoneskills.com>
pull/2722/head
Alex Popov 2022-06-24 21:25:01 +04:00 committed by GitHub
parent 7a38d05b7a
commit c3204e9200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 16 deletions

View File

@ -5,7 +5,7 @@
<CalendarButton v-if="showIcon" :icon="icon" tabindex="-1" class="p-datepicker-trigger" :disabled="$attrs.disabled" @click="onButtonClick" type="button" :aria-label="inputFieldValue"/>
<Portal :appendTo="appendTo" :disabled="inline">
<transition name="p-connected-overlay" @enter="onOverlayEnter($event)" @after-enter="onOverlayEnterComplete" @after-leave="onOverlayAfterLeave" @leave="onOverlayLeave">
<div :ref="overlayRef" :class="panelStyleClass" v-if="inline ? true : overlayVisible" :role="inline ? null : 'dialog'" @click="onOverlayClick" @mouseup="onOverlayMouseUp">
<div :ref="overlayRef" :class="panelStyleClass" v-if="inline || overlayVisible" :role="inline ? null : 'dialog'" @click="onOverlayClick" @mouseup="onOverlayMouseUp">
<template v-if="!timeOnly">
<div class="p-datepicker-group-container">
<div class="p-datepicker-group" v-for="(month,groupIndex) of months" :key="month.month + month.year">
@ -2190,10 +2190,10 @@ export default {
this.$emit('focus', event);
},
onBlur(event) {
this.$emit('blur', {originalEvent: event, value: this.input.value});
this.$emit('blur', {originalEvent: event, value: event.target.value});
this.focused = false;
this.input.value = this.formatValue(this.modelValue);
event.target.value = this.formatValue(this.modelValue);
},
onKeyDown(event) {
if (event.keyCode === 40 && this.overlay) {

View File

@ -2,11 +2,9 @@
<template v-if="inline">
<slot></slot>
</template>
<template v-else-if="mounted">
<Teleport :to="appendTo">
<slot></slot>
</Teleport>
</template>
<Teleport v-else-if="isClient" :to="appendTo">
<slot></slot>
</Teleport>
</template>
<script>
@ -24,17 +22,12 @@ export default {
default: false
}
},
data() {
return {
mounted: false
}
},
mounted() {
this.mounted = DomHandler.isClient();
},
computed: {
inline() {
return this.disabled || this.appendTo === 'self';
},
isClient () {
return DomHandler.isClient()
}
}
}