React js material ui textfield helper text position

Viewed 2069

I am working on my react js project, I am using the material UI library to edit table rows, the problem is I can't align the text field with other fields, when the helper text appears the text field moves up ?? any help i would be grateful

      <TableRow className={classes.root} >
        </TableCell>

          {edit ?    <TableCell align="justify"><TextField tfield
          value={state.Name}
          name={row.Name}
          id="Name"
          onChange={e => handle_change(e, row.Name)}
         error={Boolean(HelperText["Name"] != "") ? true : false}

          helperText={HelperText["Name"]}
       
        /></TableCell>  :  <TableCell align="left">{row.Name}</TableCell>
}
          {edit ?    <TableCell align="justify"><TextField
          value={state.address}
          name={row.address}
          id="address"
          error={Boolean(HelperText["address"] != "") ? true : false}
          helperText={HelperText["address"]}

          onChange={e => handle_change(e, row.address)}
    
        /></TableCell>  :  <TableCell align="left">{row.address}</TableCell>

}
{edit ?    <TableCell align="justify"><TextField
          value={state.commune}
          id="commune"
          name={row.commune}
          onChange={e => handle_change(e, row.commune)}
           error={Boolean(HelperText["commune"] != "") ? true : false}
          helperText={HelperText["commune"]}
       
        /></TableCell>  :  <TableCell align="left">{row.commune}</TableCell>
}
{edit ?    <TableCell align="justify">   <Select style={{ marginBottom : "10px", minWidth: 120,}}
            value={Wilaya}
          onChange={handleChangeWilaya}
          id="wilaya"
                                                     InputProps={{
        
          name={row.wilaya}
          displayEmpty
          // className={classes.selectEmpty}
          inputProps={{ 'aria-label': 'Without label' }}
          >
              {wilaya.map((item,index)=>{
                  return  <MenuItem value={item.nom.toString()} >{item.nom.toString()}</MenuItem>
              })}

          </Select></TableCell>  :  <TableCell align="left">{row.wilaya}</TableCell>
}
      </TableRow>

1 Answers

This is mentioned in the Text Field limitations in the Material UI documentation.

The workaround they propose is to add an empty helper text to all text fields that should be aligned. This moves the text fields at the same position, regardless of whether they have visible a helper text or not.

Before:

<TextField
  helperText="Please enter your name"
  id="demo-helper-text-misaligned"
  label="Name"
/>
<TextField id="demo-helper-text-misaligned-no-helper" label="Name" />

After:

<TextField
  helperText="Please enter your name"
  id="demo-helper-text-aligned"
  label="Name"
/>
<TextField
  helperText=" "
  id="demo-helper-text-aligned-no-helper"
  label="Name"
/>
Related