Skip to content

Commit

Permalink
fix: disabled drop combo tag (#912)
Browse files Browse the repository at this point in the history
Co-authored-by: Lee Chase <lee.chase@uk.ibm.com>
  • Loading branch information
lee-chase and lee-chase authored May 27, 2020
1 parent a776770 commit 1cc67ab
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
23 changes: 17 additions & 6 deletions packages/core/src/components/cv-combo-box/cv-combo-box.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<template>
<div class="cv-combo-box bx--list-box__wrapper" @focusout="onFocusOut">
<label v-if="title" :for="uid" class="bx--label" :class="{ 'bx--label--disabled': $attrs.disabled }">
{{ title }}
</label>
<label v-if="title" :for="uid" class="bx--label" :class="{ 'bx--label--disabled': disabled }">{{ title }}</label>

<div v-if="isHelper" class="bx--form__helper-text" :class="{ 'bx--form__helper-text--disabled': $attrs.disabled }">
<div v-if="isHelper" class="bx--form__helper-text" :class="{ 'bx--form__helper-text--disabled': disabled }">
<slot name="helper-text">{{ helperText }}</slot>
</div>

Expand All @@ -16,10 +14,10 @@
'bx--list-box--light': theme === 'light',
'bx--combo-box--expanded': open,
'bx--list-box--expanded': open,
'bx--combo-box--disabled bx--list-box--disabled': $attrs.disabled,
'bx--combo-box--disabled bx--list-box--disabled': disabled,
}"
:data-invalid="isInvalid"
v-bind="$attrs"
v-bind="$attr"
@keydown.down.prevent="onDown"
@keydown.up.prevent="onUp"
@keydown.enter.prevent="onEnter"
Expand All @@ -46,8 +44,10 @@
:aria-controls="uid"
aria-autocomplete="list"
role="combobox"
:aria-disabled="disabled"
:aria-expanded="open"
autocomplete="off"
:disabled="disabled"
:placeholder="label"
v-model="filter"
@input="onInput"
Expand Down Expand Up @@ -109,6 +109,7 @@ export default {
props: {
autoFilter: Boolean,
autoHighlight: Boolean,
disabled: Boolean,
invalidMessage: { type: String, default: undefined },
helperText: { type: String, default: undefined },
title: String,
Expand Down Expand Up @@ -209,6 +210,7 @@ export default {
this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
},
clearFilter() {
if (this.disabled) return;
this.internalUpdateValue('');
this.filter = '';
this.$refs.input.focus();
Expand Down Expand Up @@ -280,6 +282,7 @@ export default {
}
},
onInput() {
if (this.disabled) return;
this.doOpen(true);
this.updateOptions();
Expand All @@ -289,29 +292,34 @@ export default {
this.open = newVal;
},
onDown() {
if (this.disabled) return;
if (!this.open) {
this.doOpen(true);
} else {
this.doMove(false);
}
},
onUp() {
if (this.disabled) return;
if (this.open) {
this.doMove(true);
}
},
onEsc() {
if (this.disabled) return;
this.doOpen(false);
this.$el.focus();
},
onEnter() {
if (this.disabled) return;
this.doOpen(!this.open);
if (!this.open) {
this.onItemClick(this.highlighted);
this.$refs.input.focus();
}
},
onClick() {
if (this.disabled) return;
this.doOpen(!this.open);
if (this.open) {
this.$refs.input.focus();
Expand Down Expand Up @@ -340,17 +348,20 @@ export default {
}
},
onItemClick(val) {
if (this.disabled) return;
this.internalUpdateValue(val);
this.$refs.input.focus();
this.open = false; // close after user makes a selection
this.$emit('change', this.dataValue);
},
inputClick() {
if (this.disabled) return;
if (!this.open) {
this.doOpen(true);
}
},
inputFocus() {
if (this.disabled) return;
this.doOpen(true);
},
},
Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/components/cv-dropdown/cv-dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
:class="{ 'bx--dropdown__wrapper--inline': inline, 'cv-dropdown': !formItem }"
:style="wrapperStyleOverride"
>
<span v-if="label" :id="`${uid}-label`" class="bx--label" :class="{ 'bx--label--disabled': disabled }">
{{ label }}
</span>
<span v-if="label" :id="`${uid}-label`" class="bx--label" :class="{ 'bx--label--disabled': disabled }">{{
label
}}</span>

<div
v-if="!inline && isHelper"
Expand Down Expand Up @@ -58,10 +58,12 @@
>
<button
class="bx--dropdown-text"
:aria-disabled="disabled"
aria-haspopup="true"
:aria-expanded="open"
:aria-controls="`${uid}-menu`"
:aria-labelledby="`${uid}-label ${uid}-value`"
:disabled="disabled"
type="button"
>
<WarningFilled16 v-if="isInvalid && inline" class="bx--dropdown__invalid-icon" />
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/components/cv-tag/cv-tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
@keyup.space.prevent="$emit('remove')"
>
<span class="bx--tag__label">{{ label }}</span>
<button v-if="isFilter" class="bx--tag__close-icon" :aria-label="clearAriaLabel" @click.stop.prevent="onRemove">
<button
v-if="isFilter"
class="bx--tag__close-icon"
:aria-label="clearAriaLabel"
@click.stop.prevent="onRemove"
:disabled="disabled"
>
<Close16 />
</button>
</span>
Expand Down

0 comments on commit 1cc67ab

Please sign in to comment.