Fixed #233 - Select components may throw non-primitive key error
parent
acefc2875d
commit
0fb9cdcf22
|
@ -20,7 +20,7 @@
|
||||||
<div ref="itemsWrapper" class="p-dropdown-items-wrapper" :style="{'max-height': scrollHeight}">
|
<div ref="itemsWrapper" class="p-dropdown-items-wrapper" :style="{'max-height': scrollHeight}">
|
||||||
<ul class="p-dropdown-items p-dropdown-list p-component" role="listbox">
|
<ul class="p-dropdown-items p-dropdown-list p-component" role="listbox">
|
||||||
<li v-for="(option, i) of visibleOptions" :class="['p-dropdown-item', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option)}]"
|
<li v-for="(option, i) of visibleOptions" :class="['p-dropdown-item', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option)}]"
|
||||||
:aria-label="getOptionLabel(option)" :key="getOptionLabel(option) + '_' + i" @click="onOptionSelect($event, option)" role="option" :aria-selected="isSelected(option)">
|
:aria-label="getOptionLabel(option)" :key="getOptionRenderKey(option)" @click="onOptionSelect($event, option)" role="option" :aria-selected="isSelected(option)">
|
||||||
<slot name="option" :option="option" :index="i">
|
<slot name="option" :option="option" :index="i">
|
||||||
{{getOptionLabel(option)}}
|
{{getOptionLabel(option)}}
|
||||||
</slot>
|
</slot>
|
||||||
|
@ -89,6 +89,9 @@ export default {
|
||||||
getOptionValue(option) {
|
getOptionValue(option) {
|
||||||
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
||||||
},
|
},
|
||||||
|
getOptionRenderKey(option) {
|
||||||
|
return this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option);
|
||||||
|
},
|
||||||
isOptionDisabled(option) {
|
isOptionDisabled(option) {
|
||||||
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="p-listbox-list-wrapper" :style="listStyle">
|
<div class="p-listbox-list-wrapper" :style="listStyle">
|
||||||
<ul class="p-listbox-list" role="listbox" aria-multiselectable="multiple">
|
<ul class="p-listbox-list" role="listbox" aria-multiselectable="multiple">
|
||||||
<li v-for="(option, i) of visibleOptions" :tabindex="isOptionDisabled(option) ? null : '0'" :class="['p-listbox-item', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(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)}]"
|
||||||
:aria-label="getOptionLabel(option)" :key="getOptionLabel(option)" @click="onOptionSelect($event, option)" @touchend="onOptionTouchEnd()" @keydown="onOptionKeyDown($event, option)" role="option" :aria-selected="isSelected(option)">
|
:aria-label="getOptionLabel(option)" :key="getOptionRenderKey(option)" @click="onOptionSelect($event, option)" @touchend="onOptionTouchEnd()" @keydown="onOptionKeyDown($event, option)" role="option" :aria-selected="isSelected(option)">
|
||||||
<slot name="option" :option="option" :index="i">
|
<slot name="option" :option="option" :index="i">
|
||||||
{{getOptionLabel(option)}}
|
{{getOptionLabel(option)}}
|
||||||
</slot>
|
</slot>
|
||||||
|
@ -50,6 +50,9 @@ export default {
|
||||||
getOptionValue(option) {
|
getOptionValue(option) {
|
||||||
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
||||||
},
|
},
|
||||||
|
getOptionRenderKey(option) {
|
||||||
|
return this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option);
|
||||||
|
},
|
||||||
isOptionDisabled(option) {
|
isOptionDisabled(option) {
|
||||||
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<div ref="itemsWrapper" class="p-multiselect-items-wrapper" :style="{'max-height': scrollHeight}">
|
<div ref="itemsWrapper" class="p-multiselect-items-wrapper" :style="{'max-height': scrollHeight}">
|
||||||
<ul class="p-multiselect-items p-multiselect-list p-component" role="listbox" aria-multiselectable="true">
|
<ul class="p-multiselect-items p-multiselect-list p-component" role="listbox" aria-multiselectable="true">
|
||||||
<li v-for="(option, i) of visibleOptions" :class="['p-multiselect-item', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option)}]" role="option" :aria-selected="isSelected(option)"
|
<li v-for="(option, i) of visibleOptions" :class="['p-multiselect-item', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option)}]" role="option" :aria-selected="isSelected(option)"
|
||||||
:aria-label="getOptionLabel(option)" :key="getOptionLabel(option)" @click="onOptionSelect($event, option)" @keydown="onOptionKeyDown($event, option)" :tabindex="tabindex||'0'">
|
:aria-label="getOptionLabel(option)" :key="getOptionRenderKey(option)" @click="onOptionSelect($event, option)" @keydown="onOptionKeyDown($event, option)" :tabindex="tabindex||'0'">
|
||||||
<div class="p-checkbox p-component">
|
<div class="p-checkbox p-component">
|
||||||
<div :class="['p-checkbox-box p-component', {'p-highlight': isSelected(option)}]">
|
<div :class="['p-checkbox-box p-component', {'p-highlight': isSelected(option)}]">
|
||||||
<span :class="['p-checkbox-icon p-c', {'pi pi-check': isSelected(option)}]"></span>
|
<span :class="['p-checkbox-icon p-c', {'pi pi-check': isSelected(option)}]"></span>
|
||||||
|
@ -105,6 +105,9 @@ export default {
|
||||||
getOptionValue(option) {
|
getOptionValue(option) {
|
||||||
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
||||||
},
|
},
|
||||||
|
getOptionRenderKey(option) {
|
||||||
|
return this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option);
|
||||||
|
},
|
||||||
isOptionDisabled(option) {
|
isOptionDisabled(option) {
|
||||||
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="containerClass" role="group">
|
<div :class="containerClass" role="group">
|
||||||
<div v-for="(option, i) of options" :key="getOptionLabel(option)" :aria-label="getOptionLabel(option)" role="button" :aria-pressed="isSelected(option)"
|
<div v-for="(option, i) of options" :key="getOptionRenderKey(option)" :aria-label="getOptionLabel(option)" role="button" :aria-pressed="isSelected(option)"
|
||||||
@click="onOptionSelect($event, option, i)" @keydown.enter.prevent="onOptionSelect($event, option, i)" @keydown.space.prevent="onOptionSelect($event, option)"
|
@click="onOptionSelect($event, option, i)" @keydown.enter.prevent="onOptionSelect($event, option, i)" @keydown.space.prevent="onOptionSelect($event, option)"
|
||||||
:tabindex="isOptionDisabled(option) ? null : '0'" @focus="onFocus($event, i)" @blur="onBlur($event)" :aria-labelledby="ariaLabelledBy"
|
:tabindex="isOptionDisabled(option) ? null : '0'" @focus="onFocus($event, i)" @blur="onBlur($event)" :aria-labelledby="ariaLabelledBy"
|
||||||
:class="['p-button p-component p-button-text-only', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option), 'p-focus': (i === focusedIndex)}]">
|
:class="['p-button p-component p-button-text-only', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option), 'p-focus': (i === focusedIndex)}]">
|
||||||
|
@ -38,6 +38,9 @@ export default {
|
||||||
getOptionValue(option) {
|
getOptionValue(option) {
|
||||||
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
||||||
},
|
},
|
||||||
|
getOptionRenderKey(option) {
|
||||||
|
return this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option);
|
||||||
|
},
|
||||||
isOptionDisabled(option) {
|
isOptionDisabled(option) {
|
||||||
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue