-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[TextField] endAdornment is over/below a long label #39427
Comments
A little confused in currrent vs expected behaviour and two passsword labels.Can you provide a little more context.Also while toggling visibility for passwords why is mouse cursor shifted towards start of input instead of end? |
@SBRKH how to submit the answer? |
@SBRKH Here's a workaround you could try: <TextField
variant="outlined"
label="A really long and contrived input label"
InputLabelProps={{
sx: {
maxWidth: `calc(100% - ${isFocused ? 0 : 48}px)`,
},
}}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
onClick={handleClick}
onMouseDown={handleMouseDown}
edge="end"
>
<Visibility />
</IconButton>
</InputAdornment>
),
}}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
sx={{ width: 100 }}
/> Demo: https://codesandbox.io/s/https-github-com-mui-material-ui-issues-39427-vx2gvd?file=/demo.tsx I wouldn't change the default styles for this, customizing the const theme = createTheme({
components: {
MuiInputLabel: {
styleOverrides: {
root: ({ ownerState }) => ({
...(ownerState.focused && {
maxWidth: `calc(100% - ${isFocused ? 0 : 48}px)`,
}),
}),
},
},
},
}); |
Hi @mj12albert, |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example:
https://stackblitz.com/edit/react-uvs3ey?file=Demo.tsx
Steps:
Current behavior 😯
The label is over/below the endAdornment when is longer than the input width.
Expected behavior 🤔
The label sould be truncated with "..." in the same way it's doing when label is more long than the input width.
Context 🔦
I need to put an endAdornment for input like password (for our french users the input is "Mot de passe") and we give them an endAdornment to show their password during the register.
The fact that the end of the label is going over the endAdornment (or below) causes discomfort for some of them.
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: