Skip to content

Commit 4f908f4

Browse files
joevilchesmeta-codesync[bot]
authored andcommitted
Fix declarative blur not working (#56223)
Summary: Pull Request resolved: #56223 Calling blur() on a ref works now. Failed before bc we did not become first responder when we were focused, so resign first responder would fail and no onBlur() event would be generated. Changelog: [Internal] Reviewed By: jorge-cab Differential Revision: D98006567 fbshipit-source-id: 005c4b370b0c68ffb5e24604ad7b26e6a069729d
1 parent 402001f commit 4f908f4

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,14 +1777,14 @@ - (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context
17771777
return;
17781778
}
17791779

1780+
// Do not resignFirstRespodner if we lost focus, let whoever took focus
1781+
// becomeFirstResponder thereby resigning for us. If we resign here,
1782+
// first responder will be assigned to some ancestor view and they
1783+
// can temporarily call onFocus/onBlur
17801784
if (context.nextFocusedView == self) {
1781-
if (_eventEmitter) {
1782-
_eventEmitter->onFocus();
1783-
}
1784-
} else {
1785-
if (_eventEmitter) {
1786-
_eventEmitter->onBlur();
1787-
}
1785+
[self becomeFirstResponder];
1786+
} else if (context.previouslyFocusedView == self && context.nextFocusedView == nil) {
1787+
[self resignFirstResponder];
17881788
}
17891789

17901790
[super didUpdateFocusInContext:context withAnimationCoordinator:coordinator];

0 commit comments

Comments
 (0)