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

Reset MDC TextField?Β #924

Closed
Closed
@touficbatache

Description

Feature Requests

I opened this issue based on the request of @amsheehan on Discord.

I wanted to ask what's the best way to reset MDC Input Fields after I typed into them? For example, I typed something and submitted that thing, I want that later, the MDC TextField to be reset and not have any text in it. I tried changing its value to '' (none) and after that, I blur() the field but it doesn't work: the label doesn't return to where it was but it keeps floating without any text.

  1. UPDATE: I solved my problem by removing the mdc-textfield__label--float-above class from the label so it returns to where it was: document.querySelector('.label's class').classList.remove('mdc-textfield__label--float-above');

  2. UPDATE: Another thing occurred when MDC TextField had a required attribute and turned red: the red input color didn't go away so I did that: document.querySelector('.mdc-textfield').classList.remove('mdc-textfield--invalid');

Maybe this could "be good to add to the component": adding a function that fully resets MDC-Textfield!

Metadata

Assignees

No one assigned

    Labels

    Unresolved (Archived)Open and unresolved issues and PRs that were closed due to archiving the repository.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions