fix(core): stop emitting spurious blur for non-focused widgets on unregister#1665
fix(core): stop emitting spurious blur for non-focused widgets on unregister#1665atul-upadhyay-7 wants to merge 1 commit into
Conversation
…egister When unregistering a widget that precedes the focused one, FocusManager emitted a blur event for the removed widget even though it was never focused. Downstream handlers looking up this widget by ID got undefined and crashed. Only emit blur when the actually focused widget is removed. For non-focused widgets, silently adjust the index since the focused widget hasn't changed. Closes Karanjot786#1660
|
Warning Review limit reached
More reviews will be available in 8 minutes and 46 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ 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 |
|
Hi @atul-upadhyay-7 👋 ⭐ Star this repo before your PR merges. Why? GSSoC 2026 contributors who star get priority review and points credit. After you star, push any commit (or re-run this check). The Thanks for your contribution to TermUI. |
Summary
Fixes a bug where
FocusManager.unregister()emitted a blur event for non-focused widgets, causing downstream handlers to crash when looking up the removed widget by ID.Closes #1660
Root Cause
In the
unregister()method, when a widget that precedes the focused widget was removed (idx < this._currentIndex), the code emitted both blur and focus events:The blur event targeted the removed widget (
id) which was never focused. Handlers that looked up this widget by ID gotundefinedand crashed.Fix
_currentIndexif needed. No blur/focus events because the focused widget hasn't changed.Tests added
Verification