From f34fd0eff49e3293702ce28b6125bcf88c3eda81 Mon Sep 17 00:00:00 2001 From: Heath Chiavettone Date: Thu, 2 May 2024 12:50:25 -0700 Subject: [PATCH 1/4] Fixed React 18.3 warning about spreading key in the `AutoComplete` component --- .../src/Autocomplete/Autocomplete.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.js b/packages/mui-material/src/Autocomplete/Autocomplete.js index 2aea5bf347fb6b..afc631921613e0 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.js +++ b/packages/mui-material/src/Autocomplete/Autocomplete.js @@ -537,14 +537,18 @@ const Autocomplete = React.forwardRef(function Autocomplete(inProps, ref) { if (renderTags) { startAdornment = renderTags(value, getCustomizedTagProps, ownerState); } else { - startAdornment = value.map((option, index) => ( - - )); + startAdornment = value.map((option, index) => { + const { key, ...customTagProps }= getCustomizedTagProps({index}) + return ( + + ); + }); } } From 5882451d8717ee04d4be0c1bcf15941dcaf6f21b Mon Sep 17 00:00:00 2001 From: Diego Andai Date: Thu, 2 May 2024 17:10:29 -0400 Subject: [PATCH 2/4] Add missing cases --- .../src/useAutocomplete/useAutocomplete.test.js | 7 ++++++- .../mui-joy/src/Autocomplete/Autocomplete.test.tsx | 13 ++++++++----- .../mui-material/src/Autocomplete/Autocomplete.js | 2 +- .../src/Autocomplete/Autocomplete.test.js | 5 ++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/mui-base/src/useAutocomplete/useAutocomplete.test.js b/packages/mui-base/src/useAutocomplete/useAutocomplete.test.js index 264f0ee8f67ce2..9eeadda0cb3001 100644 --- a/packages/mui-base/src/useAutocomplete/useAutocomplete.test.js +++ b/packages/mui-base/src/useAutocomplete/useAutocomplete.test.js @@ -31,7 +31,12 @@ describe('useAutocomplete', () => { {groupedOptions.length > 0 ? (
    {groupedOptions.map((option, index) => { - return
  • {option}
  • ; + const { key, ...optionProps } = getOptionProps({ option, index }); + return ( +
  • + {option} +
  • + ); })}
) : null} diff --git a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx index 17447b87ab68e4..44e3f9cb13d28c 100644 --- a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx +++ b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx @@ -480,11 +480,14 @@ describe('Joy ', () => { renderTags={(value, getTagProps) => value .filter((x, index) => index === 1) - .map((option, index) => ( - }> - {option.title} - - )) + .map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + }> + {option.title} + + ); + }) } onChange={handleChange} autoFocus diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.js b/packages/mui-material/src/Autocomplete/Autocomplete.js index afc631921613e0..299ced34991a96 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.js +++ b/packages/mui-material/src/Autocomplete/Autocomplete.js @@ -538,7 +538,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(inProps, ref) { startAdornment = renderTags(value, getCustomizedTagProps, ownerState); } else { startAdornment = value.map((option, index) => { - const { key, ...customTagProps }= getCustomizedTagProps({index}) + const { key, ...customTagProps } = getCustomizedTagProps({ index }); return ( ', () => { renderTags={(value, getTagProps) => value .filter((x, index) => index === 1) - .map((option, index) => ) + .map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ; + }) } onChange={handleChange} renderInput={(params) => } From 8b3ab3c39a73acf90ec41077ed6b448cec67ca9c Mon Sep 17 00:00:00 2001 From: Heath C <51679588+heath-freenome@users.noreply.github.com> Date: Thu, 2 May 2024 14:58:34 -0700 Subject: [PATCH 3/4] Update packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx Signed-off-by: Heath C <51679588+heath-freenome@users.noreply.github.com> --- packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx index 44e3f9cb13d28c..4563cc4df41290 100644 --- a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx +++ b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx @@ -483,7 +483,7 @@ describe('Joy ', () => { .map((option, index) => { const { key, ...tagProps } = getTagProps({ index }); return ( - }> + }> {option.title} ); From 604feadfe3627d911c1ecb39d9dcf2599872ee48 Mon Sep 17 00:00:00 2001 From: Diego Andai Date: Mon, 6 May 2024 17:32:16 -0400 Subject: [PATCH 4/4] Reverse unnecessary change --- .../mui-joy/src/Autocomplete/Autocomplete.test.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx index 4563cc4df41290..17447b87ab68e4 100644 --- a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx +++ b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx @@ -480,14 +480,11 @@ describe('Joy ', () => { renderTags={(value, getTagProps) => value .filter((x, index) => index === 1) - .map((option, index) => { - const { key, ...tagProps } = getTagProps({ index }); - return ( - }> - {option.title} - - ); - }) + .map((option, index) => ( + }> + {option.title} + + )) } onChange={handleChange} autoFocus