question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ChakraUI Select doesn't display when used within Canvas <rect> as `foreignObject`, displays randomly (browser draw issue?)

See original GitHub issue

I wanted to try using ChakraUI Select component in a Canvas (SVG) as foreignObject.

The issue doesn’t seem to be specific to ChakraUI, I tried using React-Select component, which suffers from a similar issue.

Here’s what initially displayed by the browser: image

Once I scroll and leave the element and come back (force browser redraw I guess?) it displays: image

Reproduction video: https://youtu.be/qnVYN4ekT2k

I don’t know what’s causing this, it feels like it’s a drawing issue. I don’t know if that might be caused by ChakraUI, or a bug in Reaflow. I’ve opened an issue at https://github.com/reaviz/reaflow/issues/44.

Although, I believe it’s related to ChakraUI because the native HTML select element works just fine.

Minimal reproduction of the problem with instructions

Branch: https://github.com/Vadorequest/poc-nextjs-reaflow/tree/repro-select-not-drawn Online demo: https://poc-nextjs-reaflow-htvwfpkjc.vercel.app/

Run locally:

  • git clone https://github.com/Vadorequest/poc-nextjs-reaflow.git
  • cd poc-nextjs-reaflow && git checkout repro-select-not-drawn
  • yarn && yarn start
  • Open http://localhost:8890
  • Create a “Question” node (drag and drop it)

Version

Using @chakra-ui/react 1.2.1 Using React 17.0.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
with-heartcommented, Feb 9, 2021

All of the selects seem to work fine if I add position: fixed to the child div of foreignObject: https://codesandbox.io/s/elated-burnell-5mupm?file=/src/components/nodes/QuestionNode.tsx:2802-2882

Adding ChakraProvider to _app even makes it render with the expected styles: https://codesandbox.io/s/blazing-sea-gr9i4?file=/src/pages/_app.tsx

1reaction
with-heartcommented, Feb 10, 2021

Glad I could help 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select - Chakra UI
Select component is a component that allows users pick a value from predefined options. Ideally, it should be used when there are more...
Read more >
React chakra ui canvas width and height initializing to zero ...
I am trying to have two tabs; the first tab shows "Hello World" while the second tab has a canvas element(I am using...
Read more >
Newest 'foreignobject' Questions - Stack Overflow
I use Next.js Image component for performance and wrap it in foreignObject tag. In Chrome browser this solution works fine, but in Safari...
Read more >
Available CRAN Packages By Date of Publication
Available CRAN Packages By Date of Publication. Date, Package, Title. 2022-12-25, BDgraph, Bayesian Structure Learning in Graphical Models using Birth-Death ...
Read more >
Pro HTML5 Programming Powerful APIs for Richer Internet ...
The dynamism of web applications is provided by the use of web scripts, ... the arrival of canvas, you could only use drawing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found