Fix copy ticket button not working in Edge on Job Details page
Moved clipboard functions (copyToClipboard, fallbackCopy, showCopyFeedback) inside IIFE scope for proper closure access. Edge browser is stricter than Firefox about scope resolution - functions must be in same scope as event listeners that call them. Previously these functions were in global scope while event listeners were in IIFE scope, which worked in Firefox but failed silently in Edge. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9dee9c300a
commit
2e0baa4e35
@ -284,63 +284,63 @@
|
|||||||
.replace(/'/g, "'");
|
.replace(/'/g, "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cross-browser copy to clipboard function
|
|
||||||
function copyToClipboard(text, button) {
|
|
||||||
// Method 1: Modern Clipboard API (works in most browsers with HTTPS)
|
|
||||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
||||||
navigator.clipboard.writeText(text)
|
|
||||||
.then(function () {
|
|
||||||
showCopyFeedback(button);
|
|
||||||
})
|
|
||||||
.catch(function () {
|
|
||||||
// Fallback to method 2 if clipboard API fails
|
|
||||||
fallbackCopy(text, button);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Method 2: Legacy execCommand method
|
|
||||||
fallbackCopy(text, button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fallbackCopy(text, button) {
|
|
||||||
var textarea = document.createElement('textarea');
|
|
||||||
textarea.value = text;
|
|
||||||
textarea.style.position = 'fixed';
|
|
||||||
textarea.style.opacity = '0';
|
|
||||||
textarea.style.top = '0';
|
|
||||||
textarea.style.left = '0';
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
textarea.focus();
|
|
||||||
textarea.select();
|
|
||||||
|
|
||||||
try {
|
|
||||||
var successful = document.execCommand('copy');
|
|
||||||
if (successful) {
|
|
||||||
showCopyFeedback(button);
|
|
||||||
} else {
|
|
||||||
// If execCommand fails, use prompt as last resort
|
|
||||||
window.prompt('Copy ticket number:', text);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
// If all else fails, show prompt
|
|
||||||
window.prompt('Copy ticket number:', text);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showCopyFeedback(button) {
|
|
||||||
if (!button) return;
|
|
||||||
var original = button.textContent;
|
|
||||||
button.textContent = '✓';
|
|
||||||
setTimeout(function () {
|
|
||||||
button.textContent = original;
|
|
||||||
}, 800);
|
|
||||||
}
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var currentRunId = null;
|
var currentRunId = null;
|
||||||
|
|
||||||
|
// Cross-browser copy to clipboard function
|
||||||
|
function copyToClipboard(text, button) {
|
||||||
|
// Method 1: Modern Clipboard API (works in most browsers with HTTPS)
|
||||||
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText(text)
|
||||||
|
.then(function () {
|
||||||
|
showCopyFeedback(button);
|
||||||
|
})
|
||||||
|
.catch(function () {
|
||||||
|
// Fallback to method 2 if clipboard API fails
|
||||||
|
fallbackCopy(text, button);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Method 2: Legacy execCommand method
|
||||||
|
fallbackCopy(text, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fallbackCopy(text, button) {
|
||||||
|
var textarea = document.createElement('textarea');
|
||||||
|
textarea.value = text;
|
||||||
|
textarea.style.position = 'fixed';
|
||||||
|
textarea.style.opacity = '0';
|
||||||
|
textarea.style.top = '0';
|
||||||
|
textarea.style.left = '0';
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.focus();
|
||||||
|
textarea.select();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var successful = document.execCommand('copy');
|
||||||
|
if (successful) {
|
||||||
|
showCopyFeedback(button);
|
||||||
|
} else {
|
||||||
|
// If execCommand fails, use prompt as last resort
|
||||||
|
window.prompt('Copy ticket number:', text);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// If all else fails, show prompt
|
||||||
|
window.prompt('Copy ticket number:', text);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showCopyFeedback(button) {
|
||||||
|
if (!button) return;
|
||||||
|
var original = button.textContent;
|
||||||
|
button.textContent = '✓';
|
||||||
|
setTimeout(function () {
|
||||||
|
button.textContent = original;
|
||||||
|
}, 800);
|
||||||
|
}
|
||||||
|
|
||||||
function apiJson(url, opts) {
|
function apiJson(url, opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
opts.headers = opts.headers || {};
|
opts.headers = opts.headers || {};
|
||||||
|
|||||||
@ -6,6 +6,7 @@ This file documents all changes made to this project via Claude Code.
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed tickets not being displayed in Run Checks modal detail view (Meldingen section) by extending `/api/job-runs/<run_id>/alerts` endpoint to include both run-specific tickets (via ticket_job_runs) and job-level tickets (via ticket_scopes), ensuring newly created tickets are visible immediately in the modal instead of only after being resolved
|
- Fixed tickets not being displayed in Run Checks modal detail view (Meldingen section) by extending `/api/job-runs/<run_id>/alerts` endpoint to include both run-specific tickets (via ticket_job_runs) and job-level tickets (via ticket_scopes), ensuring newly created tickets are visible immediately in the modal instead of only after being resolved
|
||||||
|
- Fixed copy ticket button not working in Edge browser on Job Details page by moving clipboard functions (copyToClipboard, fallbackCopy, showCopyFeedback) inside IIFE scope for proper closure access (Edge is stricter than Firefox about scope resolution)
|
||||||
|
|
||||||
## [2026-02-10]
|
## [2026-02-10]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user