I have an lwc that displays content differently based on data type, filterField.html (simplification):
<template>
<div if:true={isText}>
<lightning-input value={_value} variant="label-hidden"
onchange={sendValue}></lightning-input>
</div>
<div if:true={isCheckbox}>
<lightning-input type="checkbox" value={_value} checked={_value} variant="label-hidden"
required={isRequired} onchange={sendValue}></lightning-input>
</div>
<div if:true={isPicklist}>
<lightning-combobox value={_value} options={_options} variant="label-hidden"
placeholder="--None--" onchange={sendValue}></lightning-combobox>
</div>
</template>
css:
:host {
display: table-cell;
}
This component is nested inside another lwc like this:
<table>
<template for:each={filters} for:item="field">
<tr key={field.index}><td>
<c-filter-field
name={field.name}
type={field.type}
value={field.value}
options={field.options}
onvaluechange={filterChange}>
</c-filter-field>
</td></tr>
</template>
</table>
When nested component displays lightning-combobox, expanding/collapsing it causes this error:
Error: [LWC error]: Invalid "key" attribute value in "<lightning-base-combobox-item>" in [object:vm LightningBaseCombobox (26)] for item number 0. Set a unique "key" value on all iterated child elements.
<lightning-base-combobox>
<lightning-combobox>
<c-filter-field>
at log (aura_proddebug.js:5929:17)
at logError (aura_proddebug.js:5937:7)
at i (aura_proddebug.js:9289:15)
at tmpl (baseCombobox.js:295:49)
at aura_proddebug.js:9881:29
at ReactiveObserver.observe (aura_proddebug.js:5817:15)
at isUpdatingTemplate (aura_proddebug.js:9837:15)
at runWithBoundaryProtection (aura_proddebug.js:10696:7)
at evaluateTemplate (aura_proddebug.js:9830:7)
at invokeComponentRenderMethod (aura_proddebug.js:9983:43)
The error doesn't break anything, my solution still works as expected. I ensured that the key value is unique. I tried adding the key value to c-filter-field and every other relevant tag(including inside the child itself). I, also, tried using nested component as table-row rather than cell. The error still refuses to go away.
There are no issues with other data types, even when changing values.
I am convinced that it's an lwc bug around lightning-combobox but was wondering, if I am missing something after all.