From 6e540fdb124e568c96c5e8d0239120e943c30062 Mon Sep 17 00:00:00 2001 From: emil Date: Sat, 9 May 2026 16:08:41 +0300 Subject: [PATCH] feat: wheel auto-updates on textarea input with 300ms debounce Co-Authored-By: Claude Sonnet 4.6 --- src/components/generators/WheelSpinner.astro | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/generators/WheelSpinner.astro b/src/components/generators/WheelSpinner.astro index 3f1885d..736ee57 100644 --- a/src/components/generators/WheelSpinner.astro +++ b/src/components/generators/WheelSpinner.astro @@ -205,9 +205,17 @@ Frank function showError(msg: string) { errorEl.textContent = msg; errorEl.classList.remove('hidden'); } function clearError() { errorEl.textContent = ''; errorEl.classList.add('hidden'); } - updateBtn.addEventListener('click', () => { + function applyItems() { const parsed = parseItems(); if (parsed) { items = parsed; draw(currentRotation); } + } + + updateBtn.addEventListener('click', applyItems); + + let debounceTimer: ReturnType | null = null; + textarea.addEventListener('input', () => { + if (debounceTimer) clearTimeout(debounceTimer); + debounceTimer = setTimeout(applyItems, 300); }); // ── Spin ─────────────────────────────────────────────────────────