From 93974cd2669ce4bc61c8a935868adf3320b550f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 11:19:33 +0100 Subject: [PATCH 01/11] fix(b-dropdown): click handling on close --- src/mixins/dropdown.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index c9fced295c1..1b4c8579ed0 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -305,7 +305,11 @@ export default { /* istanbul ignore next */ return } - this.visible = false + // Wrap in a `requestAF()` to allow any previous + // click handling to occur first + requestAF(() => { + this.visible = false + }) if (refocus) { // Child element is closing the dropdown on click this.$once('hidden', this.focusToggler) From d2527d1b25fa7841c60a50b595a1242333b1cc8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 16:59:00 +0100 Subject: [PATCH 02/11] Update dropdown.js --- src/mixins/dropdown.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 1b4c8579ed0..03955d009c1 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -288,27 +288,31 @@ export default { this.visible = false } }, + // Public method to show dropdown show() { - // Public method to show dropdown if (this.disabled) { return } // Wrap in a `requestAF()` to allow any previous // click handling to occur first - requestAF(() => { - this.visible = true + this.$nextTick(() => { + requestAF(() => { + this.visible = true + }) }) }, + // Public method to hide dropdown hide(refocus = false) { - // Public method to hide dropdown + /* istanbul ignore next */ if (this.disabled) { - /* istanbul ignore next */ return } // Wrap in a `requestAF()` to allow any previous // click handling to occur first - requestAF(() => { - this.visible = false + this.$nextTick(() => { + requestAF(() => { + this.visible = false + }) }) if (refocus) { // Child element is closing the dropdown on click From ffa7967cfd35845e330d4c06d39ff58cdeaf0203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 17:36:50 +0100 Subject: [PATCH 03/11] Update dropdown.js --- src/mixins/dropdown.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 03955d009c1..996ff71acdb 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -307,13 +307,7 @@ export default { if (this.disabled) { return } - // Wrap in a `requestAF()` to allow any previous - // click handling to occur first - this.$nextTick(() => { - requestAF(() => { - this.visible = false - }) - }) + this.visible = false if (refocus) { // Child element is closing the dropdown on click this.$once('hidden', this.focusToggler) @@ -399,7 +393,9 @@ export default { }, // Document click-out listener clickOutHandler(evt) { - this.hideHandler(evt) + requestAF(() => { + this.hideHandler(evt) + }) }, // Document focus-in listener focusInHandler(evt) { From 3548c49775099b5d51f9b82674c8a5dd4be04b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 17:45:08 +0100 Subject: [PATCH 04/11] Update dropdown.js --- src/mixins/dropdown.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 996ff71acdb..981027b8065 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -393,13 +393,15 @@ export default { }, // Document click-out listener clickOutHandler(evt) { - requestAF(() => { - this.hideHandler(evt) - }) + console.log('clickOutHandler') + this.hideHandler(evt) }, // Document focus-in listener focusInHandler(evt) { - this.hideHandler(evt) + console.log('focusInHandler') + setTimeout(() => { + this.hideHandler(evt) + }) }, // Keyboard nav focusNext(evt, up) { From 8761ea940428a36612bb4a11613bf057a952c70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 18:27:00 +0100 Subject: [PATCH 05/11] Update dropdown.js --- src/mixins/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 981027b8065..d9378ecffbe 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -401,7 +401,7 @@ export default { console.log('focusInHandler') setTimeout(() => { this.hideHandler(evt) - }) + }, this.inNavbar ? 100 : 0) }, // Keyboard nav focusNext(evt, up) { From 3df3ff5c704426ad2d87b6cade7ce273309f8e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 18:31:56 +0100 Subject: [PATCH 06/11] Update dropdown.js --- src/mixins/dropdown.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index d9378ecffbe..0b6f45a5fa8 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -393,15 +393,13 @@ export default { }, // Document click-out listener clickOutHandler(evt) { - console.log('clickOutHandler') this.hideHandler(evt) }, // Document focus-in listener focusInHandler(evt) { - console.log('focusInHandler') setTimeout(() => { this.hideHandler(evt) - }, this.inNavbar ? 100 : 0) + }, this.inNavbar ? 32 : 0) }, // Keyboard nav focusNext(evt, up) { From 5bf7a8f6366dc07105e2c8e9a3d57218e58c89f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 18:32:47 +0100 Subject: [PATCH 07/11] Update dropdown.js --- src/mixins/dropdown.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 0b6f45a5fa8..85e37893329 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -295,10 +295,8 @@ export default { } // Wrap in a `requestAF()` to allow any previous // click handling to occur first - this.$nextTick(() => { - requestAF(() => { - this.visible = true - }) + requestAF(() => { + this.visible = true }) }, // Public method to hide dropdown From 1481f0a178a4d4a47567233c48f012b1176069cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 18:40:04 +0100 Subject: [PATCH 08/11] Update dropdown.js --- src/mixins/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 85e37893329..503f86f359f 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -397,7 +397,7 @@ export default { focusInHandler(evt) { setTimeout(() => { this.hideHandler(evt) - }, this.inNavbar ? 32 : 0) + }, this.inNavbar ? 50 : 0) }, // Keyboard nav focusNext(evt, up) { From 6d7c365bac29600f46c82757691e56522f79f47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 18:44:59 +0100 Subject: [PATCH 09/11] Update dropdown.js --- src/mixins/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 503f86f359f..69187ed9741 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -397,7 +397,7 @@ export default { focusInHandler(evt) { setTimeout(() => { this.hideHandler(evt) - }, this.inNavbar ? 50 : 0) + }, this.inNavbar ? 100 : 0) }, // Keyboard nav focusNext(evt, up) { From 88cd1c4794101043d3b314e5d6c9c4ed98b8fa53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 18:59:16 +0100 Subject: [PATCH 10/11] Update dropdown.js --- src/mixins/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 69187ed9741..ac5031dab3d 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -397,7 +397,7 @@ export default { focusInHandler(evt) { setTimeout(() => { this.hideHandler(evt) - }, this.inNavbar ? 100 : 0) + }, this.inNavbar ? 300 : 0) }, // Keyboard nav focusNext(evt, up) { From ebe54ea2eb782d585062ae864159b3d30710ba28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Wed, 4 Nov 2020 22:10:14 +0100 Subject: [PATCH 11/11] Update dropdown.js --- src/mixins/dropdown.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index ac5031dab3d..154799be3af 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -172,6 +172,7 @@ export default { created() { // Create private non-reactive props this.$_popper = null + this.$_hideTimeout = null }, /* istanbul ignore next */ deactivated() /* istanbul ignore next: not easy to test */ { @@ -184,6 +185,7 @@ export default { this.visible = false this.whileOpenListen(false) this.destroyPopper() + this.clearHideTimeout() }, methods: { // Event emitter @@ -249,6 +251,10 @@ export default { this.$_popper.scheduleUpdate() } catch {} }, + clearHideTimeout() { + clearTimeout(this.$_hideTimeout) + this.$_hideTimeout = null + }, getPopperConfig() { let placement = PLACEMENT_BOTTOM_START if (this.dropup) { @@ -386,7 +392,8 @@ export default { hideHandler(evt) { const { target } = evt if (this.visible && !contains(this.$refs.menu, target) && !contains(this.toggler, target)) { - this.hide() + this.clearHideTimeout() + this.$_hideTimeout = setTimeout(() => this.hide(), this.inNavbar ? 300 : 0) } }, // Document click-out listener @@ -395,9 +402,7 @@ export default { }, // Document focus-in listener focusInHandler(evt) { - setTimeout(() => { - this.hideHandler(evt) - }, this.inNavbar ? 300 : 0) + this.hideHandler(evt) }, // Keyboard nav focusNext(evt, up) {