Skip to content

Commit bea42e5

Browse files
sbuggaymeta-codesync[bot]
authored andcommitted
Add focusable to view props (#56137)
Summary: Pull Request resolved: #56137 Changelog: [Internal] Adds `focusable` as a prop to iOS so we can re-use it on views for `canBecomeFocused` in AppleTV apps. We do not intend to make this an actual public API change, but it is non-destructive. Reviewed By: joevilches Differential Revision: D96752037 fbshipit-source-id: 72a55cc3d6cc589eff49ae8a129a37920f000b94
1 parent 42d98b5 commit bea42e5

File tree

6 files changed

+127
-0
lines changed

6 files changed

+127
-0
lines changed

packages/react-native/Libraries/NativeComponent/BaseViewConfig.ios.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ const validAttributesForNonEventProps = {
372372

373373
direction: true,
374374

375+
focusable: true,
376+
375377
style: ReactNativeStyleAttributes,
376378
} as const;
377379

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
#include <react/renderer/components/view/BaseTouch.h>
11+
12+
namespace facebook::react {
13+
using HostPlatformTouch = BaseTouch;
14+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
#include <react/renderer/components/view/BaseViewEventEmitter.h>
11+
12+
namespace facebook::react {
13+
using HostPlatformViewEventEmitter = BaseViewEventEmitter;
14+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#include "HostPlatformViewProps.h"
9+
10+
#include <react/renderer/core/propsConversions.h>
11+
12+
namespace facebook::react {
13+
14+
HostPlatformViewProps::HostPlatformViewProps(
15+
const PropsParserContext& context,
16+
const HostPlatformViewProps& sourceProps,
17+
const RawProps& rawProps)
18+
: BaseViewProps(context, sourceProps, rawProps),
19+
focusable(convertRawProp(
20+
context,
21+
rawProps,
22+
"focusable",
23+
sourceProps.focusable,
24+
false)) {}
25+
26+
void HostPlatformViewProps::setProp(
27+
const PropsParserContext& context,
28+
RawPropsPropNameHash hash,
29+
const char* propName,
30+
const RawValue& value) {
31+
BaseViewProps::setProp(context, hash, propName, value);
32+
33+
static auto defaults = HostPlatformViewProps{};
34+
35+
switch (hash) { RAW_SET_PROP_SWITCH_CASE_BASIC(focusable); }
36+
}
37+
38+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
#include <react/renderer/components/view/BaseViewProps.h>
11+
#include <react/renderer/core/PropsParserContext.h>
12+
13+
namespace facebook::react {
14+
15+
class HostPlatformViewProps : public BaseViewProps {
16+
public:
17+
HostPlatformViewProps() = default;
18+
HostPlatformViewProps(
19+
const PropsParserContext &context,
20+
const HostPlatformViewProps &sourceProps,
21+
const RawProps &rawProps);
22+
23+
void
24+
setProp(const PropsParserContext &context, RawPropsPropNameHash hash, const char *propName, const RawValue &value);
25+
26+
bool focusable{false};
27+
};
28+
29+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
#include <react/renderer/components/view/ViewProps.h>
11+
#include <react/renderer/core/ShadowNodeTraits.h>
12+
13+
namespace facebook::react::HostPlatformViewTraitsInitializer {
14+
15+
inline bool formsStackingContext(const ViewProps &props)
16+
{
17+
return false;
18+
}
19+
20+
inline bool formsView(const ViewProps &props)
21+
{
22+
return false;
23+
}
24+
25+
inline bool isKeyboardFocusable(const ViewProps & /*props*/)
26+
{
27+
return false;
28+
}
29+
30+
} // namespace facebook::react::HostPlatformViewTraitsInitializer

0 commit comments

Comments
 (0)