material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[TextField] Error Styles on errorText below textfield not working

Open kamleshchandnani opened this issue 9 years ago • 5 comments

errorStyle on textfield not working as expected

Versions

  • Material-UI: 0.17.4
  • React: 15.4.0
  • Browser: chrome 57

Description

The div of the error text doesn't affects the elements below it.

Expected behavior

If the height is 50px then the elements below this should move down but currently it behaves like the position is absolute.

<TextField
  hintText="Enter name"
  errorStyle = {{
    marginBottom:'50px',
    height:'20px',
    fontSize:'50px'
  }}
/>

kamleshchandnani avatar Apr 17 '17 10:04 kamleshchandnani

@kamleshchandnani The errorText container has a relative position. These components are built with Material Design in mind, and a fontSize of 50px is well outside the range of usable errorText.

https://material.io/guidelines/components/text-fields.html#text-fields-layout

Are you able to use smaller text to make this work within those guidelines?

m2mathew avatar Apr 18 '17 14:04 m2mathew

@m2mathew screenshot from 2017-04-18 20 15 48 screenshot from 2017-04-18 20 16 03

So 50px was just an idea the goal is that errorText div occupies the space below it even though when the error is not displayed. ideally the case should be that when an error is displayed then that div should be displayed and move other elements down to incorporate the space.

So in the first image the last name field is moved slightly down when the error is there else the space is not reserved for the error div it is display:none. want to achieve something like this.

kamleshchandnani avatar Apr 18 '17 14:04 kamleshchandnani

We have been porting the component on the next branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it.

oliviertassinari avatar Jun 08 '17 19:06 oliviertassinari

I can't find documentation on how to fix this bug, cause now it has the same behaviour... (Text Fields and labels of the form are jumping under the field with error). All I really need is to make MuiFormHelperText(which is inside of TextField) positioned as absolute with the bottom prop to zero + TextField will have some kind of margin-bottom. How can I do this on the TextField component?

danielkolesnik avatar Feb 11 '19 14:02 danielkolesnik

@danielkolesnik did you find a solution for the problem that you mentioned?

vaidehi2000 avatar Jul 01 '21 09:07 vaidehi2000