Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed using EditableInput in shadow DOM. #811

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

6 participants