kobaltedev / kobalte

A UI toolkit for building accessible web apps and design systems with SolidJS.
https://kobalte.dev
MIT License
1.2k stars 61 forks source link

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

Closed zhyuhan closed 2 months ago

zhyuhan commented 3 months ago

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?

jer3m01 commented 3 months ago

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.