Skip to content

Commit 0e03adc

Browse files
Nick Lefevermeta-codesync[bot]
authored andcommitted
Add support for nextFocus props to View (facebook#54021)
Summary: Pull Request resolved: facebook#54021 Adding missing `nextFocus*` props to the View props to enable correct Props 2.0 diffing. Changelog: [Internal] Reviewed By: rozele Differential Revision: D83714902 fbshipit-source-id: 9b47ba5ea3e177e72b77b1df4b6b6082848c77a4
1 parent 07fcdfe commit 0e03adc

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,51 @@ HostPlatformViewProps::HostPlatformViewProps(
9595
rawProps,
9696
"screenReaderFocusable",
9797
sourceProps.screenReaderFocusable,
98+
{})),
99+
nextFocusDown(
100+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
101+
? sourceProps.nextFocusDown
102+
: convertRawProp(
103+
context,
104+
rawProps,
105+
"nextFocusDown",
106+
sourceProps.nextFocusDown,
107+
{})),
108+
nextFocusForward(
109+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
110+
? sourceProps.nextFocusForward
111+
: convertRawProp(
112+
context,
113+
rawProps,
114+
"nextFocusForward",
115+
sourceProps.nextFocusForward,
116+
{})),
117+
nextFocusLeft(
118+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
119+
? sourceProps.nextFocusLeft
120+
: convertRawProp(
121+
context,
122+
rawProps,
123+
"nextFocusLeft",
124+
sourceProps.nextFocusLeft,
125+
{})),
126+
nextFocusRight(
127+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
128+
? sourceProps.nextFocusRight
129+
: convertRawProp(
130+
context,
131+
rawProps,
132+
"nextFocusRight",
133+
sourceProps.nextFocusRight,
134+
{})),
135+
nextFocusUp(
136+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
137+
? sourceProps.nextFocusUp
138+
: convertRawProp(
139+
context,
140+
rawProps,
141+
"nextFocusUp",
142+
sourceProps.nextFocusUp,
98143
{})) {}
99144

100145
#define VIEW_EVENT_CASE(eventType) \
@@ -130,6 +175,11 @@ void HostPlatformViewProps::setProp(
130175
RAW_SET_PROP_SWITCH_CASE_BASIC(needsOffscreenAlphaCompositing);
131176
RAW_SET_PROP_SWITCH_CASE_BASIC(renderToHardwareTextureAndroid);
132177
RAW_SET_PROP_SWITCH_CASE_BASIC(screenReaderFocusable);
178+
RAW_SET_PROP_SWITCH_CASE_BASIC(nextFocusDown);
179+
RAW_SET_PROP_SWITCH_CASE_BASIC(nextFocusForward);
180+
RAW_SET_PROP_SWITCH_CASE_BASIC(nextFocusLeft);
181+
RAW_SET_PROP_SWITCH_CASE_BASIC(nextFocusRight);
182+
RAW_SET_PROP_SWITCH_CASE_BASIC(nextFocusUp);
133183
}
134184
}
135185

@@ -982,6 +1032,46 @@ folly::dynamic HostPlatformViewProps::getDiffProps(
9821032
result["importantForAccessibility"] = toString(importantForAccessibility);
9831033
}
9841034

1035+
if (nextFocusDown != oldProps->nextFocusDown) {
1036+
if (nextFocusDown.has_value()) {
1037+
result["nextFocusDown"] = nextFocusDown.value();
1038+
} else {
1039+
result["nextFocusDown"] = folly::dynamic(nullptr);
1040+
}
1041+
}
1042+
1043+
if (nextFocusForward != oldProps->nextFocusForward) {
1044+
if (nextFocusForward.has_value()) {
1045+
result["nextFocusForward"] = nextFocusForward.value();
1046+
} else {
1047+
result["nextFocusForward"] = folly::dynamic(nullptr);
1048+
}
1049+
}
1050+
1051+
if (nextFocusLeft != oldProps->nextFocusLeft) {
1052+
if (nextFocusLeft.has_value()) {
1053+
result["nextFocusLeft"] = nextFocusLeft.value();
1054+
} else {
1055+
result["nextFocusLeft"] = folly::dynamic(nullptr);
1056+
}
1057+
}
1058+
1059+
if (nextFocusRight != oldProps->nextFocusRight) {
1060+
if (nextFocusRight.has_value()) {
1061+
result["nextFocusRight"] = nextFocusRight.value();
1062+
} else {
1063+
result["nextFocusRight"] = folly::dynamic(nullptr);
1064+
}
1065+
}
1066+
1067+
if (nextFocusUp != oldProps->nextFocusUp) {
1068+
if (nextFocusUp.has_value()) {
1069+
result["nextFocusUp"] = nextFocusUp.value();
1070+
} else {
1071+
result["nextFocusUp"] = folly::dynamic(nullptr);
1072+
}
1073+
}
1074+
9851075
return result;
9861076
}
9871077

packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ class HostPlatformViewProps : public BaseViewProps {
4949
bool renderToHardwareTextureAndroid{false};
5050
bool screenReaderFocusable{false};
5151

52+
std::optional<int> nextFocusDown{};
53+
std::optional<int> nextFocusForward{};
54+
std::optional<int> nextFocusLeft{};
55+
std::optional<int> nextFocusRight{};
56+
std::optional<int> nextFocusUp{};
57+
5258
#pragma mark - Convenience Methods
5359

5460
bool getProbablyMoreHorizontalThanVertical_DEPRECATED() const;

0 commit comments

Comments
 (0)