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. Fixes wavetermdev#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 |
Add apply_focus_fix.py (PR wavetermdev#3429) to PATCHED_FILES and sync-dev job. The focus fix is dev-only — not applied to main until tested. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Integrate PR wavetermdev#3429 by jameswolensky. When clicking from one web block to another, both webviews become unresponsive because the de-focusing block re-grabs DOM and logical focus (webview-focus flap). The fix adds guards so the de-focusing block only acts when it actually has focus: - setFocusTarget() only runs if (!focusWithin && isFocused) - nodeModel.focusNode() only runs if (!isFocused && focusWithin) Added as a PEP 723 patch script (.github/scripts/apply_focus_fix.py) following the revert-then-repatch strategy. The file is listed in PATCHED_FILES so it's reverted to upstream before each merge, then re-applied after. Ref: wavetermdev#3429 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add .github/UPSTREAM-PRS.md with all 50 open PRs categorized by: - Risk level (Zero/Low/Medium/High) - .patch suitability (Excellent/Great/Good/Caution/Risky) - File overlap matrix showing which PRs touch the same files Excludes dependabot and docs-only PRs. Includes already-integrated PRs (wavetermdev#3420, wavetermdev#3429) for reference. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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