From 2e33613cb97ab8823962c9160652c8d5324bc555 Mon Sep 17 00:00:00 2001 From: Manjesh M Pillai <56511816+m4manjesh@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:06:36 +0000 Subject: [PATCH] equality warning fix --- src/Autocomplete/Autocomplete.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Autocomplete/Autocomplete.tsx b/src/Autocomplete/Autocomplete.tsx index f70bd9006..5e5d7dabd 100644 --- a/src/Autocomplete/Autocomplete.tsx +++ b/src/Autocomplete/Autocomplete.tsx @@ -63,19 +63,18 @@ export default function Autocomplete< disabled={disabled} size={size} isOptionEqualToValue={(option, value) => { - // if the option is a key value pair, compare option.value to value - if (isKeyValueOption(option)) { - if (option.value === value) { - return true; - } + // if the option is a key value pair, compare option.value to value.value + if ( + isKeyValueOption(option) && + (isKeyValueOption(value) + ? option.value === value.value + : option.value === value) + ) { + return true; } else { // if the option is not a key value then compare option to value - if (option === value) { - return true; - } + if (option === value) return true; } - - // if the option is not a match, return false return false; }} />