-
Notifications
You must be signed in to change notification settings - Fork 154
Docs: copy button in Layer ARN not working #3832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I had a quick look at this using Firefox. This seems to be because the event handler is added to the <!-- This has the event handler -->
<a
class="copyMe"
href="https://docs.powertools.aws.dev/lambda/typescript/latest/#"
>arn:aws:lambda:us-east-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:24</a
>
<!-- This does not have an event handler -->
<img
alt="📋"
class="twemoji"
src="https://docs.powertools.aws.dev/lambda/typescript/latest/assets/external/cdn.jsdelivr.net/gh/jdecked/[email protected]/assets/svg/1f4cb.svg"
title=":clipboard:"
/> |
Assuming this is the cause of the issue, one way to address it might be to move the addition of the clipboard to CSS. Clicking on the clipboard would then activate the handler Something like: .copyMe::after {
content: '📋';
} |
Thank you @ConnorKirk - this is very useful. I don't know how to modify the icon rendering without messing with the theme, but I made a quick PoC and this works: function enableClipboardElements() {
const copyElements = document.querySelectorAll('.copyMe');
for (const element of copyElements) {
const parent = element.parentElement;
const textContent = element.textContent;
const icon = parent.querySelector('[title=":clipboard:"]');
if (icon) {
icon.setAttribute('aria-label', 'Copy to clipboard');
icon.setAttribute('role', 'button');
}
icon.dataset.clipboardText = textContent;
icon.addEventListener('click', (e) => {
e.preventDefault();
navigator.clipboard.writeText(textContent);
alert$.next('Copied to clipboard');
});
element.addEventListener('click', (e) => {
e.preventDefault();
navigator.clipboard.writeText(textContent);
alert$.next('Copied to clipboard');
});
}
} This solution:
This way, even if not super elegant, it won't matter where we click - both of them will copy the same text. |
Your solution is better though, apparently we just need to add a line in the |
This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so. |
This is now released under v2.19.0 version! |
What were you searching in the docs?
As per title, the button to copy the Lambda layer ARN doesn't work in some browsers (i.e. Safari & Firefox).
Is this related to an existing documentation section?
No response
How can we improve?
We should investigate and possibly fix it.
Got a suggestion in mind?
No response
Acknowledgment
The text was updated successfully, but these errors were encountered: