Skip to content

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

Closed
1 task done
dreamorosi opened this issue Apr 15, 2025 · 6 comments · Fixed by #3836
Closed
1 task done

Docs: copy button in Layer ARN not working #3832

dreamorosi opened this issue Apr 15, 2025 · 6 comments · Fixed by #3836
Assignees
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation

Comments

@dreamorosi
Copy link
Contributor

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

  • I understand the final update might be different from my proposed suggestion, or refused.
@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation documentation Improvements or additions to documentation labels Apr 15, 2025
@dreamorosi dreamorosi moved this from Triage to Backlog in Powertools for AWS Lambda (TypeScript) Apr 15, 2025
@ConnorKirk
Copy link
Contributor

I had a quick look at this using Firefox.
I could copy the item by clicking on it directly. Clicking on the clipboard icon did not copy the item.

This seems to be because the event handler is added to the copyMe class. The clipboard icon is a sibling to this class, rather than a child of the class.

<!-- 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:"
/>

@ConnorKirk
Copy link
Contributor

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: '📋';
}

@dreamorosi
Copy link
Contributor Author

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:

  • keeps the current docs structure and is additive
  • sets sets the text on the icon as attribute and makes it clickable

This way, even if not super elegant, it won't matter where we click - both of them will copy the same text.

@dreamorosi dreamorosi self-assigned this Apr 15, 2025
@dreamorosi dreamorosi moved this from Backlog to Working on it in Powertools for AWS Lambda (TypeScript) Apr 15, 2025
@dreamorosi
Copy link
Contributor Author

Your solution is better though, apparently we just need to add a line in the docs/stylesheet/extra.css file - let's go with that so we can avoid some event listeners.

@dreamorosi dreamorosi moved this from Working on it to Pending customer in Powertools for AWS Lambda (TypeScript) Apr 15, 2025
@dreamorosi dreamorosi moved this from Pending customer to Pending review in Powertools for AWS Lambda (TypeScript) Apr 15, 2025
@github-project-automation github-project-automation bot moved this from Pending review to Coming soon in Powertools for AWS Lambda (TypeScript) Apr 15, 2025
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

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.

@github-actions github-actions bot added pending-release This item has been merged and will be released soon and removed confirmed The scope is clear, ready for implementation labels Apr 15, 2025
Copy link
Contributor

This is now released under v2.19.0 version!

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Apr 24, 2025
@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation
Projects
Development

Successfully merging a pull request may close this issue.

2 participants