Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][Autocomplete] Fix more React 18.3 key spread warnings in demos (@wbt) #42766

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions docs/data/material/components/autocomplete/CheckboxesTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ export default function CheckboxesTags() {
options={top100Films}
disableCloseOnSelect
getOptionLabel={(option) => option.title}
renderOption={(props, option, { selected }) => (
<li {...props}>
<Checkbox
icon={icon}
checkedIcon={checkedIcon}
style={{ marginRight: 8 }}
checked={selected}
/>
{option.title}
</li>
)}
renderOption={(props, option, { selected }) => {
const { key, ...optionProps } = props;
return (
<li key={key} {...optionProps}>
<Checkbox
icon={icon}
checkedIcon={checkedIcon}
style={{ marginRight: 8 }}
checked={selected}
/>
{option.title}
</li>
);
}}
style={{ width: 500 }}
renderInput={(params) => (
<TextField {...params} label="Checkboxes" placeholder="Favorites" />
Expand Down
25 changes: 14 additions & 11 deletions docs/data/material/components/autocomplete/CheckboxesTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ export default function CheckboxesTags() {
options={top100Films}
disableCloseOnSelect
getOptionLabel={(option) => option.title}
renderOption={(props, option, { selected }) => (
<li {...props}>
<Checkbox
icon={icon}
checkedIcon={checkedIcon}
style={{ marginRight: 8 }}
checked={selected}
/>
{option.title}
</li>
)}
renderOption={(props, option, { selected }) => {
const { key, ...optionProps } = props;
return (
<li key={key} {...optionProps}>
<Checkbox
icon={icon}
checkedIcon={checkedIcon}
style={{ marginRight: 8 }}
checked={selected}
/>
{option.title}
</li>
);
}}
style={{ width: 500 }}
renderInput={(params) => (
<TextField {...params} label="Checkboxes" placeholder="Favorites" />
Expand Down
32 changes: 20 additions & 12 deletions docs/data/material/components/autocomplete/CountrySelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@ export default function CountrySelect() {
options={countries}
autoHighlight
getOptionLabel={(option) => option.label}
renderOption={(props, option) => (
<Box component="li" sx={{ '& > img': { mr: 2, flexShrink: 0 } }} {...props}>
<img
loading="lazy"
width="20"
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
{option.label} ({option.code}) +{option.phone}
</Box>
)}
renderOption={(props, option) => {
const { key, ...optionProps } = props;
return (
<Box
key={key}
component="li"
sx={{ '& > img': { mr: 2, flexShrink: 0 } }}
{...optionProps}
>
<img
loading="lazy"
width="20"
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
{option.label} ({option.code}) +{option.phone}
</Box>
);
}}
renderInput={(params) => (
<TextField
{...params}
Expand Down
32 changes: 20 additions & 12 deletions docs/data/material/components/autocomplete/CountrySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@ export default function CountrySelect() {
options={countries}
autoHighlight
getOptionLabel={(option) => option.label}
renderOption={(props, option) => (
<Box component="li" sx={{ '& > img': { mr: 2, flexShrink: 0 } }} {...props}>
<img
loading="lazy"
width="20"
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
{option.label} ({option.code}) +{option.phone}
</Box>
)}
renderOption={(props, option) => {
const { key, ...optionProps } = props;
return (
<Box
key={key}
component="li"
sx={{ '& > img': { mr: 2, flexShrink: 0 } }}
{...optionProps}
>
<img
loading="lazy"
width="20"
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
{option.label} ({option.code}) +{option.phone}
</Box>
);
}}
renderInput={(params) => (
<TextField
{...params}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ export default function FreeSoloCreateOption() {
// Regular option
return option.title;
}}
renderOption={(props, option) => <li {...props}>{option.title}</li>}
renderOption={(props, option) => {
const { key, ...optionProps } = props;
return (
<li key={key} {...optionProps}>
{option.title}
</li>
);
}}
sx={{ width: 300 }}
freeSolo
renderInput={(params) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ export default function FreeSoloCreateOption() {
// Regular option
return option.title;
}}
renderOption={(props, option) => <li {...props}>{option.title}</li>}
renderOption={(props, option) => {
const { key, ...optionProps } = props;
return (
<li key={key} {...optionProps}>
{option.title}
</li>
);
}}
sx={{ width: 300 }}
freeSolo
renderInput={(params) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ export default function FreeSoloCreateOptionDialog() {
selectOnFocus
clearOnBlur
handleHomeEndKeys
renderOption={(props, option) => <li {...props}>{option.title}</li>}
renderOption={(props, option) => {
const { key, ...optionProps } = props;
return (
<li key={key} {...optionProps}>
{option.title}
</li>
);
}}
sx={{ width: 300 }}
freeSolo
renderInput={(params) => <TextField {...params} label="Free solo dialog" />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ export default function FreeSoloCreateOptionDialog() {
selectOnFocus
clearOnBlur
handleHomeEndKeys
renderOption={(props, option) => <li {...props}>{option.title}</li>}
renderOption={(props, option) => {
const { key, ...optionProps } = props;
return (
<li key={key} {...optionProps}>
{option.title}
</li>
);
}}
sx={{ width: 300 }}
freeSolo
renderInput={(params) => <TextField {...params} label="Free solo dialog" />}
Expand Down
91 changes: 48 additions & 43 deletions docs/data/material/components/autocomplete/GitHubLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,49 +195,54 @@ export default function GitHubLabel() {
PopperComponent={PopperComponent}
renderTags={() => null}
noOptionsText="No labels"
renderOption={(props, option, { selected }) => (
<li {...props}>
<Box
component={DoneIcon}
sx={{ width: 17, height: 17, mr: '5px', ml: '-2px' }}
style={{
visibility: selected ? 'visible' : 'hidden',
}}
/>
<Box
component="span"
sx={{
width: 14,
height: 14,
flexShrink: 0,
borderRadius: '3px',
mr: 1,
mt: '2px',
}}
style={{ backgroundColor: option.color }}
/>
<Box
sx={{
flexGrow: 1,
'& span': {
color:
theme.palette.mode === 'light' ? '#586069' : '#8b949e',
},
}}
>
{option.name}
<br />
<span>{option.description}</span>
</Box>
<Box
component={CloseIcon}
sx={{ opacity: 0.6, width: 18, height: 18 }}
style={{
visibility: selected ? 'visible' : 'hidden',
}}
/>
</li>
)}
renderOption={(props, option, { selected }) => {
const { key, ...optionProps } = props;
return (
<li key={key} {...optionProps}>
<Box
component={DoneIcon}
sx={{ width: 17, height: 17, mr: '5px', ml: '-2px' }}
style={{
visibility: selected ? 'visible' : 'hidden',
}}
/>
<Box
component="span"
sx={{
width: 14,
height: 14,
flexShrink: 0,
borderRadius: '3px',
mr: 1,
mt: '2px',
}}
style={{ backgroundColor: option.color }}
/>
<Box
sx={(t) => ({
flexGrow: 1,
'& span': {
color: '#8b949e',
...t.applyStyles('light', {
color: '#586069',
}),
},
})}
>
{option.name}
<br />
<span>{option.description}</span>
</Box>
<Box
component={CloseIcon}
sx={{ opacity: 0.6, width: 18, height: 18 }}
style={{
visibility: selected ? 'visible' : 'hidden',
}}
/>
</li>
);
}}
options={[...labels].sort((a, b) => {
// Display the selected labels first.
let ai = value.indexOf(a);
Expand Down
Loading
Loading