CopyClipboardJs icon indicating copy to clipboard operation
CopyClipboardJs copied to clipboard

Paste into input fields not possible anymore

Open HenriWahl opened this issue 2 years ago • 4 comments

Hi there,

I use your CopyClipboardJS happily because it makes it so easy to add click-and-copy functionality. I recently found that it causes normal fields in forms to become unable to receive a paste from the clipboard. Do you have any idea why and how to fix this?

Regards

HenriWahl avatar Feb 16 '23 12:02 HenriWahl

Hi Henri, Thank you for your message. Can you please send more details about the problem? We need more details and an example of the problem, for checking it.

Best

BaseMax avatar Feb 16 '23 12:02 BaseMax

Wow what a fast response :-)

I use ClipBoardJS in addition to htmx like this:

<html>
  <head>
    <script src="/static/js/CopyClipboard.js"></script>
  </head>
  <body>
     <input type="search"
                 hx-boost="true"
                 hx-post="/search/"
                 hx-target="#content"
                 hx-swap="innerHTML scroll:top"
                 hx-trigger="keyup changed, keydown[key=='Enter'], search">
      <span data-copy-text="dummy-text" onclick="copy.text(this);">dummy-text</span>
  </body>
</html>

This works nicely - one click onto the dummy-text and it gets copied.

But, the input field does not accept any paste via ctrl+v or by context menu. Might the htmx stuff be the one to blame?

Thanks for any hint!

HenriWahl avatar Feb 16 '23 13:02 HenriWahl

So you want to keep the paste feature for the input tag while we have a copy to clipboard feature for the button(here is the span tag). yes?

BaseMax avatar Feb 16 '23 14:02 BaseMax

Yes, exactly.

HenriWahl avatar Feb 16 '23 14:02 HenriWahl