I’ve had a copy to clipboard function on my app for several months and I just noticed in the last day or so it’s no longer working. I haven’t made any changes to my list block or airtable fields.
As required and talked about in other posts, I have the following code in the Settings > Custom Code > Code Inside Footer section:
<script>
window.addEventListener('get-record-list-details1', (e) => {
setTimeout(() => {
document.body.addEventListener('click', (e) => {
if (e.target.closest('#list-details1 .right')) {
let copyText = e.target.parentNode.querySelector('.left');
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand('copy')
}
});
}, 50);
});
</script>
The following is my Airtable Formula field which its referencing:
'<div class="parent">' & Name & '</div><div class="copy-button">Copy</div>'
With Name being another column in the table.
Anyone else having this problem?
Hi,
By any chance could you replace your script by:
<script>
window.addEventListener('block-loaded-list-details1', () => {
window.addEventListener('get-record-list-details1', (e) => {
setTimeout(() => {
document.body.addEventListener('click', (e) => {
if (e.target.closest('#list-details1 .right')) {
let copyText = e.target.parentNode.querySelector('.left');
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand('copy');
}
});
}, 50);
});
});
</script>
And place it in the header custom code of the page settings
Also there is a semicolon missing in your original script, just after (‘copy’) - line 9
1 Like
Tried both - fixing the missing semicolon in mine and swapping to yours in header but no luck.
Is this functioning for you on your site?
Found another thread with the shoelace library details and am now using that which works!
The code is very basic, but I’m seeing some strange formatting when it comes up in my list details block?
What is supposed to to be displayed exactly?
I would need to see your Airtable formula field.
Do you use an embed field or a rich text field to display the copy to clipboard button?