material-components-web icon indicating copy to clipboard operation
material-components-web copied to clipboard

label issue with textfield

Open sistr22 opened this issue 9 years ago • 2 comments

When using the full-width multiline textfield with javascript enable, the label is missplaced (once you clicked on it to get focus and enter the text, it's missplaced).

For context this is the code I used to repro the issue:

<div id="story_content" class="mdc-textfield mdc-textfield--multiline mdc-textfield--fullwidth">
    <textarea id="story_area" class="mdc-textfield__input" rows="8" cols="40"></textarea>
    <label for="story_area" class="mdc-textfield__label">Content</label>
</div>

and later on I initialise it like: new mdc.textfield.MDCTextfield(document.querySelector('#story_content'));

sistr22 avatar Jan 23 '17 15:01 sistr22

Thanks, @Whiteseeker!

Codepen here: http://codepen.io/anon/pen/BpZKLB

Looks like it might have been fixed already, but I'm not sure about the position the label is moving to. @traviskaufman Does this look right?

sgomes avatar Jan 23 '17 15:01 sgomes

Hey @Whiteseeker,

It looks like you're using the wrong DOM here for full-width text fields. The correct DOM can be found at https://github.com/material-components/material-components-web/tree/master/packages/mdc-textfield#full-width, specifically the second div in that example:

<div class="mdc-textfield mdc-textfield--multiline mdc-textfield--fullwidth">
  <textarea class="mdc-textfield__input"
            placeholder="Full-Width multiline textfield"
            rows="8" cols="40"
            aria-label="Full-Width multiline textfield"></textarea>
</div>

Here is a corrected pen: http://codepen.io/traviskaufman/pen/PWjzbW

Hope that helps.

EDIT: As an FYI, floating labels are not present on full-width textfields. They are present on mutli-line textfields that are not full-width, but not on full-width ones.

traviskaufman avatar Jan 23 '17 16:01 traviskaufman