react-color
react-color copied to clipboard
Fixed using EditableInput in shadow DOM.
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.
I really need this.
You can implement a temporary workaround while this PR is waiting to be merged:
- Install
react-color
- Install patch-package into devDependencies
- Create
postinstall
script inpackage.json
:"postinstall": "patch-package"
- Make the above changes to
/node_modules/react-color/es/components/common/EditableInput.js
- Run
npx patch-package react-color
to save these changes to a newpatches
directory. Whenever you reinstall deps your patches will be applied to react-color
@casesandberg what's the likelihood of getting this merged?