* Fix #4567: DropDown: Labels unassociated from DropDown unless :editable="true" * Format fixpull/4992/head
parent
15debcec4a
commit
d9b5c591a7
|
@ -187,6 +187,7 @@ export default {
|
||||||
outsideClickListener: null,
|
outsideClickListener: null,
|
||||||
scrollHandler: null,
|
scrollHandler: null,
|
||||||
resizeListener: null,
|
resizeListener: null,
|
||||||
|
labelClickListener: null,
|
||||||
overlay: null,
|
overlay: null,
|
||||||
list: null,
|
list: null,
|
||||||
virtualScroller: null,
|
virtualScroller: null,
|
||||||
|
@ -218,6 +219,7 @@ export default {
|
||||||
this.id = this.id || UniqueComponentId();
|
this.id = this.id || UniqueComponentId();
|
||||||
|
|
||||||
this.autoUpdateModel();
|
this.autoUpdateModel();
|
||||||
|
this.bindLabelClickListener();
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
if (this.overlayVisible && this.isModelValueChanged) {
|
if (this.overlayVisible && this.isModelValueChanged) {
|
||||||
|
@ -229,6 +231,7 @@ export default {
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
this.unbindResizeListener();
|
this.unbindResizeListener();
|
||||||
|
this.unbindLabelClickListener();
|
||||||
|
|
||||||
if (this.scrollHandler) {
|
if (this.scrollHandler) {
|
||||||
this.scrollHandler.destroy();
|
this.scrollHandler.destroy();
|
||||||
|
@ -707,6 +710,28 @@ export default {
|
||||||
this.resizeListener = null;
|
this.resizeListener = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
bindLabelClickListener() {
|
||||||
|
if (!this.editable && !this.labelClickListener) {
|
||||||
|
const label = document.querySelector(`label[for="${this.inputId}"]`);
|
||||||
|
|
||||||
|
if (label && DomHandler.isVisible(label)) {
|
||||||
|
this.labelClickListener = () => {
|
||||||
|
DomHandler.focus(this.$refs.focusInput);
|
||||||
|
};
|
||||||
|
|
||||||
|
label.addEventListener('click', this.labelClickListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unbindLabelClickListener() {
|
||||||
|
if (this.labelClickListener) {
|
||||||
|
const label = document.querySelector(`label[for="${this.inputId}"]`);
|
||||||
|
|
||||||
|
if (label && DomHandler.isVisible(label)) {
|
||||||
|
label.removeEventListener('click', this.labelClickListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
hasFocusableElements() {
|
hasFocusableElements() {
|
||||||
return DomHandler.getFocusableElements(this.overlay, ':not([data-p-hidden-focusable="true"])').length > 0;
|
return DomHandler.getFocusableElements(this.overlay, ':not([data-p-hidden-focusable="true"])').length > 0;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue