From 86cfc8c5f6f80be9bd4897767417f91eeb750cef Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 10 Apr 2026 17:53:59 +0000 Subject: [PATCH] fix: defer contenteditable blur linkification to unblock mobile tap events When a contenteditable loses focus, the onblur handler immediately modified innerHTML to linkify URLs. On mobile, this DOM mutation causes a layout reflow between touchstart and click, making the browser cancel taps on the adjacent delete button. Deferring via requestAnimationFrame ensures the click event fires before the DOM is modified. https://claude.ai/code/session_01VZceWPhHMHCA6SELBdCPfN --- src/lib/components/Checklist.svelte | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/components/Checklist.svelte b/src/lib/components/Checklist.svelte index 5021589..f63dd3a 100644 --- a/src/lib/components/Checklist.svelte +++ b/src/lib/components/Checklist.svelte @@ -324,7 +324,14 @@ onkeydown={(e) => handleKeydown(e, item.id)} onclick={handleLinkClick} onpaste={handlePaste} - onblur={(e) => { (e.target as HTMLElement).innerHTML = linkifyText(item.text); }} + onblur={(e) => { + const el = e.target as HTMLElement; + requestAnimationFrame(() => { + if (el.isConnected && document.activeElement !== el) { + el.innerHTML = linkifyText(item.text); + } + }); + }} class="flex-1 min-w-0 bg-transparent text-sm outline-none break-words {item.checked ? 'text-[var(--text-muted)] line-through' : 'text-[var(--text)]'}" data-placeholder="List item" aria-placeholder="List item"