fix: clear status after successful clipboard and constant actions
This commit is contained in:
@@ -110,6 +110,15 @@ function setStatus(message, isError = false, timeoutMs = 1400) {
|
||||
}, timeoutMs);
|
||||
}
|
||||
|
||||
function clearStatus() {
|
||||
clearTimeout(statusTimer);
|
||||
statusTimer = null;
|
||||
if (!statusLine) return;
|
||||
statusLine.textContent = '';
|
||||
statusLine.classList.remove('is-visible');
|
||||
statusLine.classList.remove('is-error');
|
||||
}
|
||||
|
||||
function normalizeStack() {
|
||||
while (calc.stack.length > 4) {
|
||||
calc.stack.shift();
|
||||
@@ -280,7 +289,7 @@ async function copyStackValue(label) {
|
||||
if (!value) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
setStatus(`Copied ${label}`);
|
||||
clearStatus();
|
||||
} catch (error) {
|
||||
setStatus('Copy unavailable', true);
|
||||
}
|
||||
@@ -381,6 +390,7 @@ pasteButton.addEventListener('click', async () => {
|
||||
try {
|
||||
const text = await navigator.clipboard.readText();
|
||||
pasteTextIntoStack(text);
|
||||
clearStatus();
|
||||
} catch (error) {
|
||||
setStatus('Paste unavailable', true);
|
||||
}
|
||||
@@ -427,7 +437,7 @@ function openConstMenu() {
|
||||
pushEditingValueIfNeeded();
|
||||
calc.push(constant.value);
|
||||
render();
|
||||
setStatus(`Inserted ${constant.label}`);
|
||||
clearStatus();
|
||||
closeConstMenu();
|
||||
focusInput();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user