fix(date-picker): reallign popup after orientation change

pull/7119/head
J-Michalek 2025-01-20 16:50:13 +01:00
parent 10694a2902
commit 0d7694ac25
1 changed files with 25 additions and 1 deletions

View File

@ -571,6 +571,7 @@ export default {
timePickerTimer: null,
preventFocus: false,
typeUpdate: false,
matchMediaOrientationListener: null,
data() {
return {
currentMonth: null,
@ -583,7 +584,8 @@ export default {
overlayVisible: false,
currentView: this.view,
query: null,
queryMatches: false
queryMatches: false,
queryOrientation: null
};
},
watch: {
@ -637,6 +639,7 @@ export default {
mounted() {
this.createResponsiveStyle();
this.bindMatchMediaListener();
this.bindMatchMediaOrientationListener();
if (this.inline) {
if (!this.disabled) {
@ -670,6 +673,7 @@ export default {
this.unbindOutsideClickListener();
this.unbindResizeListener();
this.unbindMatchMediaListener();
this.unbindMatchMediaOrientationListener();
if (this.scrollHandler) {
this.scrollHandler.destroy();
@ -1071,6 +1075,26 @@ export default {
this.matchMediaListener = null;
}
},
bindMatchMediaOrientationListener() {
if (!this.matchMediaOrientationListener) {
const query = matchMedia(`(orientation: portrait)`);
this.queryOrientation = query;
this.matchMediaOrientationListener = () => {
this.alignOverlay();
};
this.queryOrientation.addEventListener('change', this.matchMediaOrientationListener);
}
},
unbindMatchMediaOrientationListener() {
if (this.matchMediaOrientationListener) {
this.queryOrientation.removeEventListener('change', this.matchMediaOrientationListener);
this.queryOrientation = null;
this.matchMediaOrientationListener = null;
}
},
isOutsideClicked(event) {
return !(this.$el.isSameNode(event.target) || this.isNavIconClicked(event) || this.$el.contains(event.target) || (this.overlay && this.overlay.contains(event.target)));
},