From 5761ea8d5f2783d06ad9ce6bc122316ae89517d4 Mon Sep 17 00:00:00 2001 From: celineung Date: Wed, 16 Sep 2020 18:54:24 +0200 Subject: [PATCH] Handle multiple dropdowns in navigation --- components/NavigationDropdown.vue | 10 ++- components/slices/NavigationZone.vue | 24 ++++-- .../components/slices/NavigationZone.test.js | 85 +++++++++++++------ 3 files changed, 83 insertions(+), 36 deletions(-) diff --git a/components/NavigationDropdown.vue b/components/NavigationDropdown.vue index 6feff0ff3..b48f81a33 100644 --- a/components/NavigationDropdown.vue +++ b/components/NavigationDropdown.vue @@ -14,6 +14,10 @@ export default { name: 'NavigationDropdown', props: { + dropdownIndex: { + type: String, + default: null, + }, options: { type: [Array, Object], default: null, @@ -22,7 +26,9 @@ export default { data() { return { eventListener: (event) => { - if (!event.target.classList.contains('dropdown-toggle')) { + if ( + event.target.getAttribute('dropdown-index') !== this.dropdownIndex + ) { this.closeDropdown() } }, @@ -39,7 +45,7 @@ export default { methods: { closeDropdown() { - this.$emit('closeNavigationDropdown') + this.$emit('closeNavigationDropdown', this.dropdownIndex) }, }, } diff --git a/components/slices/NavigationZone.vue b/components/slices/NavigationZone.vue index 59d0915af..42a500272 100644 --- a/components/slices/NavigationZone.vue +++ b/components/slices/NavigationZone.vue @@ -10,16 +10,19 @@ @@ -28,6 +31,7 @@