Skip to content

Commit

Permalink
AutoComplete: Fix the issue of passing an undefined key while renderi…
Browse files Browse the repository at this point in the history
…ng lists.
  • Loading branch information
CodeElixir committed Apr 10, 2024
1 parent 606485a commit fd2c728
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/lib/autocomplete/AutoCompletePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const AutoCompletePanel = React.memo(
return ObjectUtils.resolveFieldData(optionGroup, props.optionGroupLabel);
};

const getOptionRenderKey = (option) => {
return ObjectUtils.resolveFieldData(option, props.field);
};

const createFooter = () => {
if (props.panelFooterTemplate) {
const content = ObjectUtils.getJSXElement(props.panelFooterTemplate, props, props.onOverlayHide);
Expand Down Expand Up @@ -145,6 +149,7 @@ export const AutoCompletePanel = React.memo(
);
}

const key = `${index}_${typeof suggestion === 'object' ? getOptionRenderKey(suggestion) : suggestion}`;
const itemProps = mergeProps(
{
style,
Expand All @@ -153,7 +158,7 @@ export const AutoCompletePanel = React.memo(
getPTOptions(suggestion, 'item')
);

return createListItem(suggestion, undefined, index, itemProps);
return createListItem(suggestion, key, index, itemProps);
};

const createItems = () => {
Expand Down

0 comments on commit fd2c728

Please sign in to comment.