From 623992da2caaaa6287b027b00f731f0457d4c969 Mon Sep 17 00:00:00 2001 From: CodeElixir Date: Wed, 10 Apr 2024 16:05:08 +0530 Subject: [PATCH 1/2] AutoComplete: Fix the issue of passing an undefined key while rendering lists. --- components/lib/autocomplete/AutoCompletePanel.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/lib/autocomplete/AutoCompletePanel.js b/components/lib/autocomplete/AutoCompletePanel.js index e3175da483..20b58cb34e 100644 --- a/components/lib/autocomplete/AutoCompletePanel.js +++ b/components/lib/autocomplete/AutoCompletePanel.js @@ -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); @@ -145,6 +149,7 @@ export const AutoCompletePanel = React.memo( ); } + const key = `${index}_${typeof suggestion === 'object' ? getOptionRenderKey(suggestion) : suggestion}`; const itemProps = mergeProps( { style, @@ -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 = () => { From 35d3cb790daea9c416869debd30eba5bab2dea6b Mon Sep 17 00:00:00 2001 From: CodeElixir Date: Wed, 10 Apr 2024 18:47:26 +0530 Subject: [PATCH 2/2] AutoComplete: Use ObjectUtils helper class to check suggestion is object or not. --- components/lib/autocomplete/AutoCompletePanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lib/autocomplete/AutoCompletePanel.js b/components/lib/autocomplete/AutoCompletePanel.js index 20b58cb34e..ecdc640417 100644 --- a/components/lib/autocomplete/AutoCompletePanel.js +++ b/components/lib/autocomplete/AutoCompletePanel.js @@ -149,7 +149,7 @@ export const AutoCompletePanel = React.memo( ); } - const key = `${index}_${typeof suggestion === 'object' ? getOptionRenderKey(suggestion) : suggestion}`; + const key = `${index}_${ObjectUtils.isObject(suggestion) ? getOptionRenderKey(suggestion) : suggestion}`; const itemProps = mergeProps( { style,