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.

Required MDC Textfield without label

See original GitHub issue

Bugs|Feature Requests

I’m undecided between bug and feature request: basically is a different behavior compared to MDL (and its “rules and principles”). I looked for a previous discussion without results.

What MDC-Web Version are you using?

0.9.1

What browser(s) is this bug affecting?

All, latest versions

What OS are you using?

Windows 10 (64 bit)

What are the steps to reproduce the bug?

Every MDC Textfields, with a required input, but without a mdc-textfield__label within the mdc-textfield (eg. mdc-textfield--fullwidth) are not marked in any way, so users cannot distinguish mandatory and not. In MDL, as you can see at the following jsfiddle, required fields have the bottom-border set to $mdc-textfield-error-on-light (or dark).

Actual MDL behavior (with and without label)

Tha main difference is that MDL uses a <label> tag as watermark, instead MDC uses the placeholder attribute, so actual CSS rule (that add an “*” after the label content)

.mdc-textfield__input:required + .mdc-textfield__label::after {
  margin-left: 1px;
  content: "*";

  .mdc-textfield--focused & {
    color: $mdc-textfield-error-on-light;
  }

  @include mdc-theme-dark(".mdc-textfield") {
    .mdc-textfield--focused & {
      color: $mdc-textfield-error-on-dark;
    }
  }
}

doesn’t works.

I understand that without a CSS parent selector is really difficult to replicate MDL behavior, unless using javascript (my actual workaround). Waiting for a decent performance, fully supported :has() selector, a way could be to add an “*” after the placeholder content to identify required fields, but access the placeholder requires polyfills.

So I don’t know =/

What is the expected behavior?

Required fields (without a mdc-textfield__label within the mdc-textfield) should have the bottom-border set to $mdc-textfield-error-on-light (or dark).

What is the actual behavior?

Required fields (without a mdc-textfield__label within the mdc-textfield) aren’t marked in any way.

Any other information you believe would be useful?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
traviskaufmancommented, Apr 27, 2017

If I understand your issue correctly, it seems like you’re saying that there’s no way to explicitly tell when a label-less text field (e.g. a full-width text field) is required. I’ll follow up with design and see if I can get some clarification there, then we can discuss next steps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text fields - Material Design
A text field doesn't require a label if a separate but clear label indicator is already displayed adjacent to the text field. Add...
Read more >
Text Field - Material Components for the Web
A text field doesn't require a label if a separate but clear label indicator is already displayed adjacent to the text field. Add...
Read more >
MDC Textfield Boxes Not Rendering Properly - Stack Overflow
You have a text-field--outlined class on your input elements, but this is most likely not doing anything.
Read more >
@material/mwc-textfield - npm
<style> mwc-textfield { --mdc-theme-primary: green; } </style> <mwc-textfield label="My Textfield" iconTrailing="delete" required> ...
Read more >
Material input field label is not clickable - MDBootstrap
Expected behavior If I want to enter something in a material input field it should also be possible to click on the label,...
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