From 1d4ab65a79fd790f731f0c7c793bc3e4fbf9d9c8 Mon Sep 17 00:00:00 2001 From: Lee Chase Date: Fri, 24 Apr 2020 18:41:35 +0100 Subject: [PATCH] fix: dropdown value presentation (#873) Co-authored-by: Lee Chase --- .../components/cv-dropdown/cv-dropdown.vue | 23 ++++++++++++++----- storybook/stories/cv-dropdown-story.js | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/core/src/components/cv-dropdown/cv-dropdown.vue b/packages/core/src/components/cv-dropdown/cv-dropdown.vue index 66c35b8b5..cc1ea7ab4 100644 --- a/packages/core/src/components/cv-dropdown/cv-dropdown.vue +++ b/packages/core/src/components/cv-dropdown/cv-dropdown.vue @@ -22,9 +22,9 @@ :class="{ 'bx--dropdown__wrapper--inline': inline, 'cv-dropdown': !formItem }" :style="wrapperStyleOverride" > - {{ - label - }} + + {{ label }} +
- {{ internalCaption }} + @@ -79,6 +84,7 @@ :aria-hidden="!open" wh-menu-anchor="left" :aria-labelledby="`${uid}-label`" + ref="droplist" > @@ -281,8 +287,13 @@ export default { this.$el.focus(); } - if (ev.target.classList.contains('bx--dropdown-link')) { - const targetItemEl = ev.target.parentNode; + let target = ev.target; + while (!target.classList.contains('bx--dropdown-link') && this.$refs.droplist.contains(target)) { + target = target.parentNode; // try next one up + } + + if (target.classList.contains('bx--dropdown-link')) { + const targetItemEl = target.parentNode; const newValue = targetItemEl.getAttribute('data-value'); this.internalValue = newValue; diff --git a/storybook/stories/cv-dropdown-story.js b/storybook/stories/cv-dropdown-story.js index 9342b1ed4..1cec5f8c1 100644 --- a/storybook/stories/cv-dropdown-story.js +++ b/storybook/stories/cv-dropdown-story.js @@ -132,7 +132,7 @@ for (const story of storySet) { const templateString = ` ${settings.group.slots} - Option with value 10 + Option with value 10 & 10.0 Option with value 20 Option with value 30 Option with value 40