fix(macos): three Fabric focus regressions (blur, sendAccessibilityEvent, VirtualView)#3015
Merged
Saadnajmi merged 2 commits intoJul 8, 2026
Conversation
…ent, VirtualView)
Follow-up refinements on top of Thiago Vinhas's original fix: - RCTViewComponentView.blur(): only clear the window's first responder when this view actually holds it (guard on == self), matching iOS [self resignFirstResponder] semantics and avoiding stealing focus from an unrelated view. - Trim the verbose inline comments from all three changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tido64
approved these changes
Jul 8, 2026
Saadnajmi
added a commit
that referenced
this pull request
Jul 8, 2026
…lityEvent, VirtualView) (#3016) ## Summary Backport of #3015 to `0.81-stable`. Three macOS-only Fabric focus / first-responder regressions: 1. **`RCTViewComponentView.blur()`** — was a no-op (`resignFirstResponder` on `NSWindow` doesn't clear the focused subview). Now clears via `makeFirstResponder:nil`, guarded on `self`. 2. **Fabric `setAccessibilityFocus`** — the macOS branch was empty; added `makeFirstResponder:` + `NSAccessibilityFocusedUIElementChangedNotification`. 3. **`RCTVirtualViewComponentView`** — added `acceptsFirstResponder` / `accessibilityHitTest:` hooks so keyboard/VoiceOver navigation unhides flagged-offscreen views. All changes are macOS-gated; iOS/visionOS behavior is unchanged. ## Test Plan Same as #3015 — builds clean (RNTester-macOS, BUILD SUCCEEDED); every change is inside a `#if TARGET_OS_OSX` / `#else` branch. ## Credit Original work by @tvinhas in #2959 (commit cherry-picked to retain authorship). Supersedes #2959. Co-authored-by: Thiago Vinhas <thiago@vinhas.net> --------- Co-authored-by: Thiago Vinhas <thiago@vinhas.net> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #2959 (the original PR's source fork is disabled, so that branch can no longer be updated). This carries the same three macOS Fabric focus/first-responder fixes forward, with @tvinhas's original commit cherry-picked to preserve authorship credit, plus one small refinement.
The three regressions were surfaced while validating the "Verify focus changes" item on #2901.
1.
RCTViewComponentView.blur()was a no-opresignFirstResponderonNSWindowdoesn't clear the focused subview, soref.blur()from JS did nothing. Now clears the first responder viamakeFirstResponder:nil, guarded onselfso it only clears focus when this view actually holds it — matching iOS[self resignFirstResponder]semantics and avoiding stealing focus from an unrelated view.2. Fabric
setAccessibilityFocuswas a silent no-op on macOSsynchronouslyDispatchAccessbilityEventOnUIThread:had a#if !TARGET_OS_OSXguard with no#else, soAccessibilityInfo.setAccessibilityFocus(reactTag)did nothing on the Fabric path. Added the macOS branch (makeFirstResponder:+NSAccessibilityFocusedUIElementChangedNotification), mirroring the old-arch path inRCTAccessibilityManager.mm.3.
RCTVirtualViewComponentViewkeyboard-nav hooksAdded
acceptsFirstResponderandaccessibilityHitTest:to the macOS branch so keyboard/Tab and VoiceOver navigation unhide flagged-offscreen views under thehideOffscreenVirtualViewsoptimization. Partial by design (a fullyhidden=YESview is dropped from the responder chain — full fix needs a hide-strategy redesign, tracked as follow-up).Difference from #2959
if ([[self window] firstResponder] == self)guard onblur()for iOS-parity / to avoid focus-stealing.Test plan
xcodebuild -scheme RNTester-macOS -destination 'generic/platform=macOS') — BUILD SUCCEEDED.#if TARGET_OS_OSX/#else) and preserve existing iOS/visionOS behavior.Credit
Original work by @tvinhas in #2959 (commit cherry-picked to retain authorship).
Co-authored-by: Thiago Vinhas thiago@vinhas.net