Uh oh!
There was an error while loading. Please reload this page.
fix: stop a de-focusing block from re-grabbing focus - #3429
Conversation
blockClicked is React state and lags one commit, so the focus effect in BlockFull also runs while a block is losing focus (blockClicked still true, isFocused false). It could not distinguish a real click from a focus loss and re-grabbed both DOM and logical focus. With two web blocks this makes them fight over focus indefinitely (webview-focus flaps null <-> id), leaving both webviews unresponsive to input. Guard the re-focus so a block only pulls DOM focus in when it is the focused node, and only claims logical focus when the click actually landed inside it. Fixeswavetermdev#3428
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughUpdated Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes#3428
Problem
With two
webblocks open, clicking from one into the other makes both webviews unresponsive — buttons/links don't click, the URL bar can't be edited, typing does nothing. Only the block header icons still respond.webview-focusflaps continuously between the two webview ids andnull; focus is granted then revoked within a few ms, so no input lands. Terminal→web is fine; only web→web breaks.In
BlockFull,blockClickedis state and lags one commit, so the focus effect also runs while a block is losing focus (blockClickedstill true,isFocusedfalse). The effect could not distinguish a real click from a focus loss, so the de-focusing block re-grabbed both DOM focus (setFocusTarget) and logical focus (focusNode). With two web blocks each doing this, they fight indefinitely. A single webview settles because there is no competitor.Fix
Use
focusWithin(does DOM focus currently sit inside this block) to tell the two cases apart:setFocusTarget) only when this block is the focused node.focusNode) only when the click actually landed inside this block.A block that is losing focus now satisfies neither condition, so it no longer re-grabs focus, and the two web blocks stop fighting.
Test Plan
webview-focusno longer flaps in the logs while idling on a web block