Skip to content
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

KLO-227 : Copy button is not giving feedback of copying. #146

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

nxtCoder19
Copy link
Contributor

Resolves kloudlite/kloudlite#66

Attachment

Screenshot 2024-03-14 at 3 04 17 PM Screenshot 2024-03-14 at 3 08 12 PM Screenshot 2024-03-14 at 3 08 31 PM

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @nxtCoder19 - I've reviewed your changes and they look great!

General suggestions:

  • Ensure consistent user feedback for repeated copy actions within short intervals.
  • Consider the impact of icon size changes on the overall UI design and alignment.
  • Review the necessity of conditional checks before executing copy actions to avoid potential user confusion.
  • Remove commented-out code that is no longer needed to maintain code cleanliness.
Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: all looks good

Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨

Share Sourcery

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +65 to +73
const handleCopy = () => {
copy(url);
setCopied(true);
toast.success('Registry url copied successfully.');

setTimeout(() => {
setCopied(false);
}, 3000);
};
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): The handleCopy function introduces a 3-second delay before resetting the copied state to false. While this works for visual feedback, consider the user experience if the user attempts to copy the URL again within those 3 seconds. The current implementation will not provide feedback for the second copy action. It might be beneficial to allow the toast message to be triggered on every copy action, regardless of the copied state, to ensure the user receives consistent feedback.

Comment on lines +83 to +85
if (!copied) {
handleCopy();
}
Copy link

Choose a reason for hiding this comment

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

issue (code_refinement): The conditional check if (!copied) before calling handleCopy might lead to a scenario where the user cannot copy the URL again until the copied state is reset. This could be confusing if the user wants to copy the URL multiple times in quick succession. Consider removing this condition to allow for a more flexible user experience.

@@ -82,25 +82,27 @@ export const CopyButton = ({
title: ReactNode;
value: string;
}) => {
const [_, setCopyIcon] = useState(<CopySimple />);
// const [_, setCopyIcon] = useState(<CopySimple />);
const [copied, setCopied] = useState(false);
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): The introduction of the copied state to manage the icon change in CopyButton is a good enhancement for user feedback. However, ensure that the onSuccess callback of useClipboard is properly handling the case where the copy action might fail for any reason. Currently, the copied state is only set to false after a delay, without considering the success of the copy action.

@@ -82,25 +82,27 @@
title: ReactNode;
value: string;
}) => {
const [_, setCopyIcon] = useState(<CopySimple />);
Copy link

Choose a reason for hiding this comment

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

nitpick (code_refinement): Commenting out the previous state declaration without removing it indicates a transition phase or an uncertainty about the removal. If the copied state fully replaces the need for setCopyIcon, it's cleaner to remove the commented-out code to avoid confusion and maintain code cleanliness.

copy(value);
}}
className="flex flex-row gap-md items-center select-none group cursor-pointer"
>
<span>{title}</span>
<span className="invisible group-hover:visible">
<CopySimple size={10} />
{copied ? <Check size={12} /> : <CopySimple size={12} />}
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): The change in icon size from the default to 12 for both Check and CopySimple icons is a subtle but important UI detail. Ensure that this size change integrates well with the overall design and doesn't cause any alignment or scaling issues, especially when the icon state changes from not copied to copied.

@nxtCoder19 nxtCoder19 merged commit e0fc651 into release-v1.0.5 Mar 14, 2024
4 checks passed
@nxtCoder19 nxtCoder19 deleted the update/copy-button branch March 18, 2024 04:21
abdheshnayak pushed a commit that referenced this pull request Oct 28, 2024
KLO-227 : Copy button is not giving feedback of copying.
tulsiojha pushed a commit that referenced this pull request Nov 1, 2024
KLO-227 : Copy button is not giving feedback of copying.
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
KLO-227 : Copy button is not giving feedback of copying.
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.

[KLO-227] Copy button is not giving feedback of copying.
2 participants