Merge pull request #7119 from J-Michalek/fix/datepicker-and-select-realign-after-orientation-change
fix(date-picker-and-select): realign after orientation changepull/7129/head
commit
ee12f40984
|
@ -571,6 +571,7 @@ export default {
|
||||||
timePickerTimer: null,
|
timePickerTimer: null,
|
||||||
preventFocus: false,
|
preventFocus: false,
|
||||||
typeUpdate: false,
|
typeUpdate: false,
|
||||||
|
matchMediaOrientationListener: null,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentMonth: null,
|
currentMonth: null,
|
||||||
|
@ -583,7 +584,8 @@ export default {
|
||||||
overlayVisible: false,
|
overlayVisible: false,
|
||||||
currentView: this.view,
|
currentView: this.view,
|
||||||
query: null,
|
query: null,
|
||||||
queryMatches: false
|
queryMatches: false,
|
||||||
|
queryOrientation: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -637,6 +639,7 @@ export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
this.createResponsiveStyle();
|
this.createResponsiveStyle();
|
||||||
this.bindMatchMediaListener();
|
this.bindMatchMediaListener();
|
||||||
|
this.bindMatchMediaOrientationListener();
|
||||||
|
|
||||||
if (this.inline) {
|
if (this.inline) {
|
||||||
if (!this.disabled) {
|
if (!this.disabled) {
|
||||||
|
@ -670,6 +673,7 @@ export default {
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
this.unbindResizeListener();
|
this.unbindResizeListener();
|
||||||
this.unbindMatchMediaListener();
|
this.unbindMatchMediaListener();
|
||||||
|
this.unbindMatchMediaOrientationListener();
|
||||||
|
|
||||||
if (this.scrollHandler) {
|
if (this.scrollHandler) {
|
||||||
this.scrollHandler.destroy();
|
this.scrollHandler.destroy();
|
||||||
|
@ -1071,6 +1075,26 @@ export default {
|
||||||
this.matchMediaListener = null;
|
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) {
|
isOutsideClicked(event) {
|
||||||
return !(this.$el.isSameNode(event.target) || this.isNavIconClicked(event) || this.$el.contains(event.target) || (this.overlay && this.overlay.contains(event.target)));
|
return !(this.$el.isSameNode(event.target) || this.isNavIconClicked(event) || this.$el.contains(event.target) || (this.overlay && this.overlay.contains(event.target)));
|
||||||
},
|
},
|
||||||
|
|
|
@ -227,13 +227,15 @@ export default {
|
||||||
searchTimeout: null,
|
searchTimeout: null,
|
||||||
searchValue: null,
|
searchValue: null,
|
||||||
isModelValueChanged: false,
|
isModelValueChanged: false,
|
||||||
|
matchMediaOrientationListener: null,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
clicked: false,
|
clicked: false,
|
||||||
focused: false,
|
focused: false,
|
||||||
focusedOptionIndex: -1,
|
focusedOptionIndex: -1,
|
||||||
filterValue: null,
|
filterValue: null,
|
||||||
overlayVisible: false
|
overlayVisible: false,
|
||||||
|
queryOrientation: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -247,6 +249,7 @@ export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
this.autoUpdateModel();
|
this.autoUpdateModel();
|
||||||
this.bindLabelClickListener();
|
this.bindLabelClickListener();
|
||||||
|
this.bindMatchMediaOrientationListener();
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
if (this.overlayVisible && this.isModelValueChanged) {
|
if (this.overlayVisible && this.isModelValueChanged) {
|
||||||
|
@ -259,6 +262,7 @@ export default {
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
this.unbindResizeListener();
|
this.unbindResizeListener();
|
||||||
this.unbindLabelClickListener();
|
this.unbindLabelClickListener();
|
||||||
|
this.unbindMatchMediaOrientationListener();
|
||||||
|
|
||||||
if (this.scrollHandler) {
|
if (this.scrollHandler) {
|
||||||
this.scrollHandler.destroy();
|
this.scrollHandler.destroy();
|
||||||
|
@ -792,6 +796,26 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
hasFocusableElements() {
|
hasFocusableElements() {
|
||||||
return getFocusableElements(this.overlay, ':not([data-p-hidden-focusable="true"])').length > 0;
|
return getFocusableElements(this.overlay, ':not([data-p-hidden-focusable="true"])').length > 0;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue