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

[mwc-textfield] breaks UI if `type` is set to 'submit', 'reset', 'button'

Open yinonov opened this issue 4 years ago • 3 comments

Describe the bug the types values of 'submit', 'reset', 'button' will render the native input element as a button, therefore breaks the UI and place a button instead of the expected contenteditable input.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior The above mentioned types should be restricted / ignored or fallback to a default value and keep textfield as a contenteditable input.

Screenshots image

yinonov avatar Sep 25 '21 09:09 yinonov

Thanks for the bug report! Given that this looks obviously broken, and that there are probably very few use cases for submit, reset or button types, I think we can just add some documentation and Typescript type validation.

dfreedm avatar Sep 29 '21 22:09 dfreedm

Fair enough!

yinonov avatar Sep 30 '21 04:09 yinonov

@dfreedm do you think would be a good approach to throw an error when using these types? Once they are not int TextFieldType and are being used at type property: @property({type: String}) type: TextFieldType = 'text'; Or maybe at the renderInput return the mwc-button?

schirrel avatar Jun 04 '22 22:06 schirrel

M3 now has explicit supported and unsupported text field types that are enforced with typescript

asyncliz avatar Aug 02 '23 02:08 asyncliz