ic-ui-kit icon indicating copy to clipboard operation
ic-ui-kit copied to clipboard

Internal issue 3122 - TypeScript error on autocorrect in HTMLIcTextFieldElement

Open ticket-sync[bot] opened this issue 3 months ago • 2 comments

There is an issue with incompatible types when using ICDS with the shadow-dom-testing-library.

The following code:

const textField = container.querySelector('ic-text-field') as HTMLIcTextFieldElement;
await waitFor(() => expect(textField).toHaveClass('hydrated'));
const textInput = await within(textField).findByShadowRole('textbox'); 

gives the following error for the textField inside the within function:

Argument of type 'HTMLIcTextFieldElement' is not assignable to parameter of type 'HTMLElement'.
  Types of property 'autocorrect' are incompatible.
    Type 'string' is not assignable to type 'boolean'.
      Type 'string' is not assignable to type 'boolean'.ts(2345)

 A workaround is as follows:

const textField = container.querySelector('ic-text-field') as unknown as HTMLElement;

ticket-sync[bot] avatar Oct 16 '25 13:10 ticket-sync[bot]

Breaking change to make it a boolean

MI6-255 avatar Oct 22 '25 09:10 MI6-255

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement says:

HTMLElement.autocorrect https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/autocorrect A boolean that represents whether or not text input by a user should be automatically corrected. This reflects the autocorrect HTML global attribute.

However the examples show it accepting "on", "off" or "", as has been implemented for the textfield component https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/autocorrect#value

ad9242 avatar Oct 22 '25 09:10 ad9242