question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Textfield] Border lines of Textfield cross over the text label shrinked by MuiInputLabel

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Borders of Textfield component cross over the shrinked text label. image

Expected Behavior 🤔

Border lines overlapping with the shrinked text label are hidden. image

Steps to Reproduce 🕹

https://codesandbox.io/s/elegant-leakey-zsflw?file=/src/App.tsx

source code
import {
  createTheme,
  Stack,
  TextField,
  ThemeProvider
} from "@material-ui/core";
import React from "react";

const theme = createTheme({
  components: {
    MuiInputLabel: {
      defaultProps: { shrink: true }
    }
  }
});

function App() {
  return (
    <ThemeProvider theme={theme}>
      <Stack sx={{ m: 5 }} spacing={2}>
        {/*NG*/}
        <TextField label="Abcdefghi" />
        {/*OK*/}
        <TextField label="Abcdefghi" InputLabelProps={{ shrink: true }} />
      </Stack>
    </ThemeProvider>
  );
}

export default App;

Steps:

  1. shrink: true is specified in theme.
  2. InputLabelProps = {{shrink: true}} is not specified in TextField.

Context 🔦

Your Environment 🌎

`npx @material-ui/envinfo`
my browser: Google Chrome 90.0.4430.212(Official Build)(x86_64)
my pc: macOS Big Sur ver 11.2.2

npx @material-ui/envinfo

  System:
    OS: Linux 5.4 Debian GNU/Linux 10 (buster) 10 (buster)
  Binaries:
    Node: 14.17.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.13 - /usr/local/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @emotion/react: ^11.4.0 => 11.4.0 
    @emotion/styled: ^11.3.0 => 11.3.0 
    @material-ui/core: ^5.0.0-alpha.35 => 5.0.0-alpha.35 
    @material-ui/icons: ^5.0.0-alpha.35 => 5.0.0-alpha.35 
    @material-ui/private-theming:  5.0.0-alpha.35 
    @material-ui/styled-engine:  5.0.0-alpha.34 
    @material-ui/system:  5.0.0-alpha.35 
    @material-ui/types:  6.0.1 
    @material-ui/unstyled:  5.0.0-alpha.35 
    @material-ui/utils:  5.0.0-alpha.35 
    @types/react: ^17.0.8 => 17.0.9 
    react: ^17.0.2 => 17.0.2 
    react-dom: ^17.0.2 => 17.0.2 
    typescript: ^4.1.2 => 4.3.2 

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
RobTFcommented, Dec 9, 2021

There is a bug;

If I run my app with no theme overrides, text fields look like this

image

If I put the following into my theme setup;

    components: {
        MuiFormLabel: {
            styleOverrides: {
                root: {
                    fontSize: 16,
                },
            },
        },
        MuiFormHelperText: {
            styleOverrides: {
                root: {
                    fontSize: 12,
                },
            },
        },
    },

It looks like this;

image

Something, somewhere is not taking into account of the overridden font sizes.

2reactions
eps1loncommented, Jun 7, 2021

Pretty sure this is a general problem when we reach into *Props but ignore theme default props.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Textfield] Border lines of Textfield cross over the text label ...
Borders of Textfield component cross over the shrinked text label. ... Border lines overlapping with the shrinked text label are hidden.
Read more >
material ui textField border doesn't show completely
To remove label of text field you can achieve this by two way. Solution 1. - Just add InputLabelProps={{shrink: false}} property to ...
Read more >
InputLabel API - Material UI - MUI
if true , the label will indicate that the input is required. shrink, bool, false. If true , the label is shrunk.
Read more >
Text fields - Material Design
Place label text within the boundary of a text field box; Ensure text field outlines or strokes meet 3:1 minimum color contrast ratio...
Read more >
Mui outlined input border color. Props ... - Thought Sprinklers
The text field calls the onChanged callback whenever the user changes the text in ... the border The label value in outlined overlaps...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found