From 18f6307ab719d5466a1403e40467eec342177f6a Mon Sep 17 00:00:00 2001 From: Cagatay Civici Date: Tue, 2 Feb 2021 17:25:37 +0300 Subject: [PATCH] Fixed #915 - Tooltip focus fails with some input components --- src/components/inputnumber/InputNumber.vue | 2 +- src/components/tooltip/Tooltip.js | 30 ++++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/components/inputnumber/InputNumber.vue b/src/components/inputnumber/InputNumber.vue index 542731b11..8a338349b 100755 --- a/src/components/inputnumber/InputNumber.vue +++ b/src/components/inputnumber/InputNumber.vue @@ -820,7 +820,7 @@ export default { }, computed: { containerClass() { - return ['p-inputnumber p-component', this.class, { + return ['p-inputnumber p-component p-inputwrapper', this.class, { 'p-inputwrapper-filled': this.filled, 'p-inputwrapper-focus': this.focused, 'p-inputnumber-buttons-stacked': this.showButtons && this.buttonLayout === 'stacked', diff --git a/src/components/tooltip/Tooltip.js b/src/components/tooltip/Tooltip.js index a1c21b26b..adbf4afb3 100755 --- a/src/components/tooltip/Tooltip.js +++ b/src/components/tooltip/Tooltip.js @@ -236,25 +236,33 @@ function isOutOfBounds(el) { return (targetLeft + width > viewport.width) || (targetLeft < 0) || (targetTop < 0) || (targetTop + height > viewport.height); } +function getTarget(el) { + return DomHandler.hasClass(el, 'p-inputwrapper') ? DomHandler.findSingle(el, 'input'): el; +} + const Tooltip = { beforeMount(el, options) { - el.$_ptooltipModifiers = options.modifiers; - el.$_ptooltipValue = options.value; - bindEvents(el); + let target = getTarget(el); + target.$_ptooltipModifiers = options.modifiers; + target.$_ptooltipValue = options.value; + bindEvents(target); }, unmounted(el) { - remove(el); - unbindEvents(el); + let target = getTarget(el); + remove(target); + unbindEvents(target); - if (el.$_ptooltipScrollHandler) { - el.$_ptooltipScrollHandler.destroy(); - el.$_ptooltipScrollHandler = null; + if (target.$_ptooltipScrollHandler) { + target.$_ptooltipScrollHandler.destroy(); + target.$_ptooltipScrollHandler = null; } }, updated(el, options) { - el.$_ptooltipModifiers = options.modifiers; - el.$_ptooltipValue = options.value; - } + let target = getTarget(el); + target.$_ptooltipModifiers = options.modifiers; + target.$_ptooltipValue = options.value; + }, + }; export default Tooltip;