Disabled option support for Listbox
parent
d51c2ae811
commit
da0a8c6689
|
@ -8,8 +8,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="p-listbox-list-wrapper" :style="listStyle">
|
<div class="p-listbox-list-wrapper" :style="listStyle">
|
||||||
<ul class="p-listbox-list">
|
<ul class="p-listbox-list">
|
||||||
<li v-for="(option, i) of visibleOptions" tabindex="0" :class="['p-listbox-item', {'p-highlight': isSelected(option)}]" :aria-label="getOptionLabel(option)"
|
<li v-for="(option, i) of visibleOptions" :tabindex="isOptionDisabled(option) ? null : '0'" :class="['p-listbox-item', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option)}]"
|
||||||
:key="getOptionLabel(option)" @click="onOptionSelect($event, option)" @touchend="onOptionTouchEnd()" @keydown="onOptionKeyDown($event, option)">
|
:aria-label="getOptionLabel(option)" :key="getOptionLabel(option)" @click="onOptionSelect($event, option)" @touchend="onOptionTouchEnd()" @keydown="onOptionKeyDown($event, option)">
|
||||||
<slot :option="option" :index="i">
|
<slot :option="option" :index="i">
|
||||||
{{getOptionLabel(option)}}
|
{{getOptionLabel(option)}}
|
||||||
</slot>
|
</slot>
|
||||||
|
@ -34,7 +34,8 @@ export default {
|
||||||
metaKeySelection: Boolean,
|
metaKeySelection: Boolean,
|
||||||
filter: Boolean,
|
filter: Boolean,
|
||||||
optionLabel: null,
|
optionLabel: null,
|
||||||
optionValue: null
|
optionValue: null,
|
||||||
|
optionDisabled: null
|
||||||
},
|
},
|
||||||
optionTouched: false,
|
optionTouched: false,
|
||||||
data() {
|
data() {
|
||||||
|
@ -49,8 +50,11 @@ export default {
|
||||||
getOptionValue(option) {
|
getOptionValue(option) {
|
||||||
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
||||||
},
|
},
|
||||||
|
isOptionDisabled(option) {
|
||||||
|
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
||||||
|
},
|
||||||
onOptionSelect(event, option) {
|
onOptionSelect(event, option) {
|
||||||
if (this.disabled) {
|
if (this.disabled || this.isOptionDisabled(option)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue