Sunday, 13 October 2019

Copy to clipboard is including parent of targeted element

Edit - Additional info:

Simplified sandbox - https://codesandbox.io/s/stupefied-leftpad-k6eek

Demo: https://imgur.com/a/SDWTQno

Issue doesn't seem to be happening on firefox but is on chrome and other browsers


I have a div that renders a template (simplified in above link) which is hooked up to a button that calls a function that copies to clipboard.

However when pasting what is copied to the clipboard, the contents is centered and upon further inspection the container div styles ({ display: 'flex', margin: '0 auto', justifyContent: 'center' }) are also included in what is selected.

How do I exclude the parent div from the copy, it should only be targeting the html code in the literal template (preferably just what I'm targeting by id - #signature-preview-workspace, therefore shouldn't be centered?

Thanks in advance



from Copy to clipboard is including parent of targeted element

No comments:

Post a Comment