-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Autocomplete] Composing endAdornment
overlaps collapse/expand icon
#28465
Comments
The code you posted is not the same as the one you linked. Following our example, fixes the issue: renderInput={(params) => {
return (
<TextField
// eslint-disable-next-line react/jsx-props-no-spreading
{...params}
label={'Select service providers'}
InputProps={{
...params.InputProps,
endAdornment: (
<React.Fragment>
- <CircularProgress color={'inherit'} size={20} />
+ {loading ? <CircularProgress color="inherit" size={20} /> : null}
{params.InputProps.endAdornment}
</React.Fragment>
),
}}
/>
)
}} |
@eps1lon are you sure that it fixes the issue? The issue is not when the loading indicator is being displayed but rather how. I removed conditional rendering for loading indicator to be always visible for demo purposes. The issue is still there with this code: renderInput={(params) => {
return (
<TextField
// eslint-disable-next-line react/jsx-props-no-spreading
{...params}
label={'Select service providers'}
InputProps={{
...params.InputProps,
endAdornment: (
<React.Fragment>
{loading ? (
<CircularProgress color={'inherit'} size={20} />
) : null}
{params.InputProps.endAdornment}
</React.Fragment>
),
}}
/>
)
}} Here you can take another example, which worked without a problem before migration: renderInput={(params) => {
const textFieldProps: TextFieldProps = {
label: 'Job Titles',
variant: 'outlined',
placeholder: 'Start typing to filter the results...',
InputProps: {
...params.InputProps,
...{
endAdornment: (
<>
{loading ? (
<CircularProgress color={'inherit'} size={20} />
) : (
<Tooltip title={'Select All'}>
<IconButton size={'small'} onClick={handleSelectAll}>
<SelectAll />
</IconButton>
</Tooltip>
)}
{params.InputProps.endAdornment}
</>
),
},
},
}
return React.createElement(TextField, { ...params, ...textFieldProps })
}} And it is positioned as expected with the close button. |
Please consider re-opening this @eps1lon. We are having the same issue with the following code: renderInput={(params) => {
return (
<TextField
{...params}
size="small"
name={name || ''}
label={label}
placeholder={placeholder}
helperText={helperText}
error={error}
required={required}
InputProps={{
...params.InputProps,
endAdornment: (
<>
{loading ? <CircularProgress color="inherit" size={20} /> : null}
{params.InputProps.endAdornment}
</>
),
}}
/>
);
}} digging a bit and comparing with the example in the docs, it appears this is only an issue when using |
It doesn't look like this bug report has enough info for one of us to reproduce it. Please provide a CodeSandbox (https://material-ui.com/r/issue-template-latest). Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve |
@eps1lon reproduced it without a problem in this Sandbox: https://codesandbox.io/s/elastic-haze-tmmmo?file=/src/Demo.tsx I can't understand why there is not enough info to reproduce it... It happens with Autocomplete |
There was no full codesandbox. Just snippets of code. We don't try to patch them up because it takes up a considerable amount of our time and might not resemble the original issue. Now that we have codesandbox.io/s/elastic-haze-tmmmo?file=/src/Demo.tsx, that's another issue. But that's unrelated to loading indicators. How to make them work is already described in the documentation you linked. The problem is common for all composed |
endAdornment
overlaps collapse/expand icon
I ran into the same issue. Using Autocomplete component with As I understand, it is because Autocomplete use an In my opinion, the proper way to deal with that, is to override your Autocomplete styles via your theme configuration. // under theme.components
MuiAutocomplete: {
styleOverrides: {
root: {
'.MuiOutlinedInput-root.MuiInputBase-sizeSmall': {
padding: '39px',
// or padding: theme.spacing(X) if you want to be more precise & already defined your theme
},
},
},
}, Each Autocomplete with Hope this helps you. |
Ran into the same issue with the prop @DeLm0re's code does fix the issue. |
Some css to fix it
|
My Autocomplete dropdown list depends on database query results from my textfield input. I found Autocomplete's freeSolo field was a better solution for me, rather than Autocomplete's default to assume a static dropdown list with a ArrowDropDownIcon. Using Autocomplete's freeSolo field removes the ArrowDropDownIcon from my textfield and is the better solution for in my case. |
@DeLm0re would you like to create a PR for the proposed changes? We can use the screenshot tests to verify that this works in all scenarios. |
@mnajdova Of course, I look into it when I have time. I am a just a bit confuse with this comment : // In Autocomplete.js
[`& .${outlinedInputClasses.root}.${inputBaseClasses.sizeSmall}`]: {
// Don't specify paddingRight, as it overrides the default value set when there is only
// one of the popup or clear icon as the specificity is equal so the latter one wins
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 6,
[`& .${autocompleteClasses.input}`]: {
padding: '2.5px 4px 2.5px 6px',
},
}, Looks like this piece of code was written when I can re-write it to patch this issue however. |
If someone has time to create a PR with the fix I would be happy to review it. It's hard to say if any of these is the correct fix to the solution without checking if there are no visual regressions in other scenarios. |
Issue seems to be resolved, as of |
Still happening in version 6 |
See #28465 (comment) for general problem description.
Current Behavior 😯
endAdornment
overlaps with the loading indicator.Example code:
Expected Behavior 🤔
Loading indicator should be positioned next to the endAdornment as it was in v4
Steps to Reproduce 🕹
Frozen CodeSandbox: https://codesandbox.io/s/autocomplete-composed-endadornment-vemqi
Steps:
Context 🔦
Not really sure what to write here... Well, the code above worked perfectly in v4 but now it seems to be broken for me...
Your Environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: