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.

onclone is not working

See original GitHub issue

Bug reports:

I want to change the display property of myDiv from none to block inside the cloned document. The reason to do this is that I want to hide my div in the actual dom. When I am trying to use onclone option of html2canvas, to change the property it is not reflecting. Can someone please check if I am missing something here? Please find below the link to the reproducer.

Codesandbox

Specifications:

  • html2canvas version tested with: 1.0.0-rc.7
  • Browser & version: Chrome 87
  • Operating system: Windows 10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
niklasvhcommented, Jul 14, 2021

The onclone is working, but as you are rendering an element with display:none, it has no width/height. Changing it to use visibility and it works justs fine: https://codesandbox.io/s/xenodochial-northcutt-002g6?file=/src/App.js

0reactions
lighthaus205commented, Sep 6, 2022

Using the visibility property worked me for me as well! Using the display property was causing some issues, for example sometimes the font was not correctly rendered.

Read more comments on GitHub >

github_iconTop Results From Across the Web

html2canvas Option onclone Not Working as Expected with ...
It seems that the issue is due to the fact that the styles of the clone element used by jsPDF keep the same...
Read more >
Screenshot of hidden div using html2canvas
html2canvas provides an option called 'onclone' by passing the cloned document. You can set the visibility of your hidden ...
Read more >
How to use the html2canvas function in html2canvas
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
oncopy Event
The oncopy event occurs when the user starts a copy process in the browser. The oncopy event occurs when the user copies element...
Read more >
Window onClose not working in KendoReact
The problem is that clicking the X to close the popup doesn't do anything at all. Maximize and minimize work, but not the...
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