Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Update textfield label position when value is changed from JavaScript #822

Closed
@jesperkristensen

Description

@jesperkristensen

What MDC-Web Version are you using?

Not sure. Neither material-components-web.min.js nor material-components-web.css seem to contain a version number. But the issue looks to be the same on the master branch of this repository.

What browser(s) is this bug affecting?

Tested on Firefox 54 and Chrome 59.

What OS are you using?

Windows 10

What are the steps to reproduce the bug?

I am using MDC-Web together with Angular (v1) following this guide:
https://material.io/components/web/docs/framework-integration/
And specifically this link from the guide:
https://plnkr.co/edit/b4v160c186ErrPG5vNza?p=preview

I have a MDC Textfield as described in the guide above.
When the value of the text field is updated from JavaScript via Angular, the position of the label does not change to reflect if the text field is empty or not.

  1. open https://plnkr.co/edit/EMfKHSByb2Z7VaxBOS3K?p=preview
  2. Type something in the second text box (the one that is not MDC styled)
  3. Observe that the MDC styled input is updated, but the label and the value overlap each other.

When I look at https://github.com/material-components/material-components-web/blob/master/packages/mdc-textfield/foundation.js it seems to set LABEL_FLOAT_ABOVE when the component is loaded and when focus is lost.
But there does not seem to be a way to tell it that the value has been changed from JavaScript, which should update LABEL_FLOAT_ABOVE.

What is the expected behavior?

There should be some API or other way for the framework to tell the component that the text field value has changed, and it should update its label position to match the updated value.

What is the actual behavior?

The field value and the field label are written on top of each other, making them unreadable.

Any other information you believe would be useful?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions