Skip to content

Commit

Permalink
fix: [M3-8617] - Autocomplete Popper re-rendering causing test failur…
Browse files Browse the repository at this point in the history
…es (#10978)

Co-authored-by: Banks Nussman <banks@nussman.us>
  • Loading branch information
bnussman-akamai and bnussman authored Sep 20, 2024
1 parent 27abb00 commit 5b7c237
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
10 changes: 1 addition & 9 deletions packages/manager/src/components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from './Autocomplete.styles';

import type { AutocompleteProps } from '@mui/material/Autocomplete';
import type { SxProps } from '@mui/system';
import type { TextFieldProps } from 'src/components/TextField';

export interface EnhancedAutocompleteProps<
Expand All @@ -42,10 +41,6 @@ export interface EnhancedAutocompleteProps<
placeholder?: string;
/** Label for the "select all" option. */
selectAllLabel?: string;
/**
* The prop that allows defining CSS style overrides for the PopperComponent.
*/
sxPopperComponent?: SxProps;
textFieldProps?: Partial<TextFieldProps>;
}

Expand Down Expand Up @@ -93,7 +88,6 @@ export const Autocomplete = <
placeholder,
renderOption,
selectAllLabel = '',
sxPopperComponent,
textFieldProps,
value,
...rest
Expand All @@ -110,9 +104,6 @@ export const Autocomplete = <

return (
<MuiAutocomplete
PopperComponent={(props) => {
return <CustomPopper {...props} sx={sxPopperComponent} />;
}}
options={
multiple && !disableSelectAll && options.length > 0
? optionsWithSelectAll
Expand Down Expand Up @@ -172,6 +163,7 @@ export const Autocomplete = <
);
}}
ChipProps={{ deleteIcon: <CloseIcon /> }}
PopperComponent={CustomPopper}
clearOnBlur={clearOnBlur}
data-qa-autocomplete
defaultValue={defaultValue}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ export const CreateAPITokenDrawer = (props: Props) => {
onChange={(_, selected) =>
form.setFieldValue('expiry', selected.value)
}
slotProps={{
popper: {
sx: {
'&& .MuiAutocomplete-listbox': {
padding: 0,
},
},
},
}}
sx={{
'&& .MuiAutocomplete-inputRoot': {
paddingLeft: 1,
Expand All @@ -224,11 +233,6 @@ export const CreateAPITokenDrawer = (props: Props) => {
padding: '0px 2px',
},
}}
sxPopperComponent={{
'&& .MuiAutocomplete-listbox': {
padding: 0,
},
}}
disableClearable
label="Expiry"
options={expiryList}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ export const PhoneVerification = ({
} ${getCountryFlag(country.code)}`,
value: country.code,
}))}
sxPopperComponent={{
'& .MuiPaper-root.MuiAutocomplete-paper': {
border: '1px solid #3683dc',
maxHeight: '285px',
overflow: 'hidden',
textWrap: 'nowrap',
width: 'fit-content',
slotProps={{
paper: {
sx: {
border: '1px solid #3683dc',
maxHeight: '285px',
overflow: 'hidden',
textWrap: 'nowrap',
width: 'fit-content',
},
},
}}
textFieldProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ export const TimezoneForm = (props: Props) => {
<StyledRootContainer>
<Stack>
<Autocomplete
sxPopperComponent={{
maxHeight: '285px',
overflow: 'hidden',
slotProps={{
popper: {
sx: {
maxHeight: '285px',
overflow: 'hidden',
},
},
}}
value={timezoneList.find(
(option) => option.value === timezoneValue
Expand Down

0 comments on commit 5b7c237

Please sign in to comment.