Skip to content

Commit 7f4b703

Browse files
committed
fix copy butotn animation
1 parent b3ee360 commit 7f4b703

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

templates/index.jinja

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,14 @@
579579
// Copy functions for Monaco editors
580580
function copyDockerfile() {
581581
const content = dockerfileEditor ? dockerfileEditor.getValue() : '';
582-
copyToClipboard(content, 'Dockerfile copied!');
582+
const button = event.target.closest('button');
583+
copyToClipboard(content, 'Dockerfile copied!', button);
583584
}
584585
585586
function copyCompose() {
586587
const content = composeEditor ? composeEditor.getValue() : '';
587-
copyToClipboard(content, 'Compose file copied!');
588+
const button = event.target.closest('button');
589+
copyToClipboard(content, 'Compose file copied!', button);
588590
}
589591
590592
// WebSocket streaming functionality
@@ -808,20 +810,17 @@
808810
{% endif %}
809811
810812
// Copy to clipboard functionality
811-
async function copyToClipboard(text, successMessage) {
813+
async function copyToClipboard(text, successMessage, targetButton) {
812814
try {
813815
await navigator.clipboard.writeText(text);
814-
// Show success feedback
815-
const buttons = document.querySelectorAll('button');
816-
buttons.forEach(btn => {
817-
if (btn.textContent.includes('Copy')) {
818-
const originalText = btn.innerHTML;
819-
btn.innerHTML = '' + (successMessage || 'Copied!');
820-
setTimeout(() => {
821-
btn.innerHTML = originalText;
822-
}, 2000);
823-
}
824-
});
816+
// Show success feedback only on the specific button
817+
if (targetButton) {
818+
const originalText = targetButton.innerHTML;
819+
targetButton.innerHTML = '' + (successMessage || 'Copied!');
820+
setTimeout(() => {
821+
targetButton.innerHTML = originalText;
822+
}, 2000);
823+
}
825824
} catch (err) {
826825
console.error('Failed to copy: ', err);
827826
}

0 commit comments

Comments
 (0)