mui / mui/material-ui

[TextField] Long labels break layout

Open
#12,255 44 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs scope: text field
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

The textfield layout is not responsive when there are long labels.

  • This is a v1.3.1 issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

According to Material Design, long labels should be correctly positioned within the available input space:
2018-07-23 13 49 06

Current Behavior

  • Two or more line labels are overlapping the underline line.

Steps to Reproduce

https://codesandbox.io/s/6xjr79vx3w

import React from 'react';
import TextField from '@material-ui/core/TextField';

class TextFields extends React.Component {
  render() {
    return (
      <form noValidate autoComplete="off">
        <TextField
          id="name"
          label="This is a long label because things"
        />
      </form>
    );
  }
}

export default TextFields;

Context

  • All content is usually content managed, which means that the content editors could enter in label that may break the layout.
  • If the enter in a label that is longer than the available space, example: "Do you have any association with a government entity?", and the user is loading the page in an iPhone 5, there is no enough space to render the label in only one line.

Your Environment

Tech Version
Material-UI v1.3.1
React v16.4.1
browser Chrome

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and the Material UI TextField component used there. Confirm the overlapping two-line label behavior at narrow widths, then compare the result with the expected Material Design positioning shown in the issue. Done means long labels remain correctly positioned without overlapping the underline.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.