Clipboard to copy dropdown value includes the 'x' to clear value

Hello, I am using the dash Clipboard component where the user can click on it to copy the contents (value) of a target dropdown. I was able to succesfully get it to work; however, the clipboard strangely also copies a line break and a “x” sign to used to clear values (see below).

image

So instead of the desired:
‘44154’

to be copied to the clipboard, it instead copies:

'44154
× ’

How can I avoid this?

By the same principle, if I set the ‘target-id’ to be a dashtable, all text, including pagination numbers, column names etc are added to the clipboard. Is there a way to only copy the data within the datatable? Is there some way to choose a specific property of a component to copy when Clipboard is pressed?

Any help would be appreciated.

Hi @justin13601 and welcome to the dash community :slightly_smiling_face:

When you are using dcc.Clipboard with either the Dropdown or the DataTable, it’s better to update the content prop in a callback. You can find an example here: Clipboard | Dash for Python Documentation | Plotly

1 Like

Hi @AnnMarieW, thanks so much for your reply.

Seems like I just forgot to scroll down on the documentation :sweat_smile:.

Appreciate the help!

1 Like