Skip to content

Conversation

@ldeong
Copy link

@ldeong ldeong commented Oct 21, 2025

Summary

Resolves issue #156 - Enables users to click truncated addresses to copy the full address to clipboard.

✋ Taking on this issue!

Changes

  • Added click handler to copy full address to clipboard using navigator.clipboard API
  • Integrated react-hot-toast for user feedback (success/error messages)
  • Added visual feedback:
    • Green color when address is copied (2 second duration)
    • Blue hover state to indicate clickability
    • Cursor pointer to show interactivity
  • Added helpful tooltip: "Click to copy full address"

Benefits

  • Users can now easily copy full addresses for faucets or external tools
  • Improved UX with visual feedback and toast notifications
  • No breaking changes to component API
  • Uses existing project dependencies (react-hot-toast)

Testing

  • Tested clipboard API functionality
  • Verified toast notifications appear correctly
  • Confirmed visual states (hover, copied) work as expected
  • Handles copy failures gracefully with error toast

Screenshots

The address text now has:

  • Cursor pointer on hover
  • Blue color on hover
  • Green color when copied
  • Toast notification: "Address copied to clipboard!"

Bounty Payment Wallet: 1PqVB8PvS9i1kwc76V4SeSJi3S2SSipGkr

Looking forward to contributing to LasticUI!

…XYZ#156)

Resolves issue LasticXYZ#156 - Enable copying full addresses by clicking truncated address displays

Changes:
- Added click handler to copy full address to clipboard
- Integrated react-hot-toast for user feedback
- Added visual feedback (green color) when address is copied
- Added hover state (blue color) to indicate clickability
- Added helpful tooltip "Click to copy full address"

Benefits:
- Users can now easily copy full addresses for faucets/external tools
- Improved UX with visual feedback and toast notifications
- No breaking changes to component API

Testing:
- Tested clipboard API functionality
- Verified toast notifications appear correctly
- Confirmed visual states (hover, copied) work as expected

Bounty Payment Wallet: 1PqVB8PvS9i1kwc76V4SeSJi3S2SSipGkr
Copilot AI review requested due to automatic review settings October 21, 2025 12:03
@vercel
Copy link

vercel bot commented Oct 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lastic-ui Error Error Oct 22, 2025 4:02am

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds click-to-copy functionality for truncated blockchain addresses, improving user experience when working with wallet addresses in the LasticUI interface.

Key Changes:

  • Implemented clipboard copying with visual feedback using color changes and toast notifications
  • Added hover and copied states to indicate interactivity
  • Integrated graceful error handling for clipboard operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 21 to 23
setTimeout(() => {
setCopied(false)
}, 2000)
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setTimeout is not cleaned up when the component unmounts or when a new copy operation occurs. Store the timeout ID and clear it in a cleanup function to prevent state updates on unmounted components and avoid multiple overlapping timeouts.

Copilot uses AI. Check for mistakes.
Comment on lines 38 to 44
<span
className={`text-sm font-medium cursor-pointer hover:text-blue-500 transition-colors ${copied ? 'text-green-500' : ''}`}
onClick={handleCopyAddress}
title="Click to copy full address"
>
{shortAddress}
</span>
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The span element should be replaced with a button element to ensure proper keyboard accessibility. Screen reader users and keyboard-only users cannot interact with this clickable span. Additionally, add role='button' and onKeyDown handler if keeping the span, though a button element is the preferred solution.

Suggested change
<span
className={`text-sm font-medium cursor-pointer hover:text-blue-500 transition-colors ${copied ? 'text-green-500' : ''}`}
onClick={handleCopyAddress}
title="Click to copy full address"
>
{shortAddress}
</span>
<button
type="button"
className={`text-sm font-medium cursor-pointer hover:text-blue-500 transition-colors ${copied ? 'text-green-500' : ''}`}
onClick={handleCopyAddress}
title="Click to copy full address"
style={{ background: 'none', border: 'none', padding: 0 }}
>
{shortAddress}
</button>

Copilot uses AI. Check for mistakes.
// Assuming use of a utility to shorten addresses; you'll need to implement this based on your needs
const shortAddress = `${value.substring(0, 6)}…${value.substring(value.length - 4)}`

const handleCopyAddress = async () => {
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The navigator.clipboard API requires HTTPS or localhost context and appropriate permissions. Consider checking for clipboard API availability before attempting to use it, as it may not be available in all browser contexts or could be blocked by permissions policies.

Suggested change
const handleCopyAddress = async () => {
const handleCopyAddress = async () => {
if (!navigator.clipboard || typeof navigator.clipboard.writeText !== 'function') {
toast.error('Clipboard API not available in this browser or context.')
return
}

Copilot uses AI. Check for mistakes.
Fixes all 3 Copilot review comments:

1. ✅ Check clipboard API availability before use
   - Prevents errors in non-HTTPS contexts
   - Shows user-friendly error message

2. ✅ Proper setTimeout cleanup
   - Store timeout ID and clear on unmount
   - Prevents memory leaks and state updates on unmounted components

3. ✅ Replace span with button element
   - Improves keyboard accessibility
   - Screen reader compatible
   - Maintains visual styling with CSS reset

Bitcoin Wallet: 1PqVB8PvS9i1kwc76V4SeSJi3S2SSipGkr

Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant