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.
-
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');
-
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!