GithubHelp home page GithubHelp logo

Comments (5)

i23098 avatar i23098 commented on July 28, 2024 1

Can't really reproduce in there, but I did made an example at https://codesandbox.io/embed/react-color-example-59-forked-1kezj7?fontsize=14&hidenavigation=1&theme=dark

The bug is when clicking the "Done" that hides the color picker... but it only happens when using iframes from another website. In my case, in salesforce 3 iframes, one inside another, are created!

I managed to get it working by forcing a patch with https://www.npmjs.com/package/patch-package

diff --git a/node_modules/react-color/es/components/common/Saturation.js b/node_modules/react-color/es/components/common/Saturation.js
index 8e2f44c..1749ee8 100644
--- a/node_modules/react-color/es/components/common/Saturation.js
+++ b/node_modules/react-color/es/components/common/Saturation.js
@@ -52,8 +52,14 @@ export var Saturation = function (_ref) {
       var container = this.container;
 
       var renderWindow = window;
-      while (!renderWindow.document.contains(container) && renderWindow.parent !== renderWindow) {
-        renderWindow = renderWindow.parent;
+      var lastRenderWindow = window;
+      try {
+        while (!renderWindow.document.contains(container) && renderWindow.parent !== renderWindow) {
+          lastRenderWindow = renderWindow;
+          renderWindow = renderWindow.parent;
+        }
+      } catch (e) {
+        renderWindow = lastRenderWindow; // inside iframe it throws error... use last accessible
       }
       return renderWindow;
     }
diff --git a/node_modules/react-color/lib/components/common/Saturation.js b/node_modules/react-color/lib/components/common/Saturation.js
index 0a80592..e1bb4d0 100644
--- a/node_modules/react-color/lib/components/common/Saturation.js
+++ b/node_modules/react-color/lib/components/common/Saturation.js
@@ -74,8 +74,14 @@ var Saturation = exports.Saturation = function (_ref) {
       var container = this.container;
 
       var renderWindow = window;
-      while (!renderWindow.document.contains(container) && renderWindow.parent !== renderWindow) {
-        renderWindow = renderWindow.parent;
+      var lastRenderWindow = window;
+      try {
+        while (!renderWindow.document.contains(container) && renderWindow.parent !== renderWindow) {
+          lastRenderWindow = renderWindow;
+          renderWindow = renderWindow.parent;
+        }
+      } catch (e) {
+        renderWindow = lastRenderWindow; // inside iframe it throws error... use last accessible
       }
       return renderWindow;
     }

from react-color.

jaywcjlove avatar jaywcjlove commented on July 28, 2024 1

image

You are not using @uiw/react-color. You should go to react-color to ask the wrong question.

from react-color.

i23098 avatar i23098 commented on July 28, 2024

Just found similar issue that's reported in react-color - casesandberg/react-color#806

from react-color.

jaywcjlove avatar jaywcjlove commented on July 28, 2024

Can you give me a reproducible example using codesandbox.io?

@i23098

from react-color.

i23098 avatar i23098 commented on July 28, 2024

Just found similar issue that's reported in react-color - casesandberg/react-color#806

I'll close bug here, bug is already open there :)

from react-color.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.