Skip to content

Conversation

@Nuurek
Copy link

@Nuurek Nuurek commented Mar 16, 2021

When I tried to use react-color inside of a Shadow DOM then none of the text inputs worked. Digging down into the code I found this single line that was trying to access the active element from the top-level document.

In such a scenario:

<body>
  <custom-web-component>
    <AnyPickerWithEditableInput>
      <EditableInput/>
    <AnyPickerWithEditableInput/>
  <custom-web-component/>
<body/>

where the node of custom-web-component is the Shadow Root, document.activeElement was returning the Shadow Root node. Changing it to getRootNode() returns correct active elements and inputs start working.

@Holybasil
Copy link

I really need this.

@lfriis
Copy link

lfriis commented Mar 31, 2023

You can implement a temporary workaround while this PR is waiting to be merged:

  1. Install react-color
  2. Install patch-package into devDependencies
  3. Create postinstall script in package.json: "postinstall": "patch-package"
  4. Make the above changes to /node_modules/react-color/es/components/common/EditableInput.js
  5. Run npx patch-package react-color to save these changes to a new patches directory. Whenever you reinstall deps your patches will be applied to react-color

@dkaps125
Copy link

@casesandberg what's the likelihood of getting this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants