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

Can't select LocalizedRichTextField on tests by selecting their Label

Open nicolasolmospurple opened this issue 3 years ago • 2 comments

I am trying to dispatch a change event by selecting the label that is assigned to the LocalizedRichInput. Jest returns an error stating that the label has not control associated. I have checked if I missed using the id attribute. Everything looks normal. Both id and for are setted.

Expected behavior

I need to be able to select that field and dispatch an event on it.

Screenshots

image

Additional context

    "jest": "27.3.1",
    "@testing-library/react": "12.1.2",
    "@testing-library/react-hooks": "7.0.2",
    "@testing-library/user-event": "^14.2.0",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-intl": "5.21.0",
    "react-router-dom": "5.3.0",
    "@commercetools-uikit/localized-rich-text-input": "^14.0.6",

nicolasolmospurple avatar Jul 26 '22 18:07 nicolasolmospurple

Hello @nicolasolmospurple,

I believe you may not be setting the for attribute properly. The format of the for attribute should be id.selectedLanguage

See snippet below.

      <label for="test-id.en">lorem</label>
      <LocalizedRichTextInput
        id="test-id"
        value={{
          en: "",
          de: ""
        }}
        onChange={(event) =>
          console.log("event.target.value", event.target.value)
        }
        selectedLanguage="en"
      />

Let me know if this was helpful.

Rhotimee avatar Jul 27 '22 13:07 Rhotimee

This issue has been marked as 'stale' due to its inactivity for the last 14 days. Please, add a new comment to keep the conversation going; otherwise, the issue will be closed in two weeks.

github-actions[bot] avatar Aug 23 '22 02:08 github-actions[bot]