mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-02 04:27:39 +00:00
fix: reset copy state after copying in MarkdownCodeBlock component
There were 2 issues. The copy state was not being reset after copying, which caused the "Copied!" message to persist indefinitely. The return value from the copy function was not being used to determine if the copy was successful. Even on false(i.e. copy unsuccessful), the user would see a success message.
This commit is contained in:
@@ -43,7 +43,13 @@ export default function MarkdownCodeBlock({
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => copyTextToClipboard(rawContent).then(() => setCopied(true))}
|
||||
onClick={() =>
|
||||
copyTextToClipboard(rawContent).then((success) => {
|
||||
if (success) {
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
}
|
||||
})}
|
||||
className="absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600"
|
||||
>
|
||||
{copied ? 'Copied!' : 'Copy'}
|
||||
|
||||
Reference in New Issue
Block a user