kobalte icon indicating copy to clipboard operation
kobalte copied to clipboard

Type mismatch when assigning `ref` to `TextField.TextArea`

Open zhyuhan opened this issue 1 year ago • 1 comments

Describe the bug When trying to assign a ref of type HTMLTextAreaElement to a TextField.TextArea element, there is a type error of

Type 'HTMLTextAreaElement' is not assignable to type 'HTMLFormElement | ((el: HTMLFormElement) => void) | undefined'.
  Type 'HTMLTextAreaElement' is missing the following properties from type 'HTMLFormElement': acceptCharset, action, elements, encoding, and 11 more.ts(2322)

A similar type mismatch happens when using a callback for the ref prop.

To Reproduce Steps to reproduce the behavior:

  1. Declare a new ref variable with type HTMLTextAreaElement
  2. Create a new TextField.TextArea element
  3. Assign the variable to the ref prop of the TextArea
  4. See TypeScript error

Expected behavior There should be no type errors at all.

Additional context Seems like the ref prop had the type HTMLTextAreaElement previously, but was changed to HTMLFormElement in #381. Was this intended?

zhyuhan avatar May 04 '24 08:05 zhyuhan

Thanks for the report, HTMLTextAreaElement should extend HTMLFormElement and not cause any type errors but I might've been mistaken, I'll have a look and fix the type.

jer3m01 avatar May 13 '24 11:05 jer3m01