Field getting focus wrongly with "CopyToClipboard" Action
Hi Guys!
I have created a JavaScript function to be used within some components, allowing users to copy values to the Clipboard. This is done in a legacy way, by creating a textarea, inserting the value, and then executing the copy action.
When I open the modal action and select an item to copy without interacting with input forms, it works like a charm. Also, when using "body" with the plugin, it works seamlessly.
However, when I click on another input field and then try to copy, the copied value is from the last focused field.
Example:
Works: Open Action -> Merge Fields -> Click on list -> Copy perfectly;
Works: Open Action -> Add some info to Body -> Merge Fields -> Click on list -> Copy perfectly;
Doesn't work: Open Action -> Click on subject -> Click on merge fields -> Even if I click on the body, the focus continues to be on the last input I clicked on.
Do you guys have any ideas? I've tried forcing but it still doesn't work. Initially, I attempted to focus on the created textarea in my script, but it still isn't functioning as expected.
2 Replies
JS:
Livewire Component
Example: