Skip to content

Commit 43bf756

Browse files
committed
fix(scrollview): Fix issue with focusable elements inside a scrollview
1 parent 410d0ac commit 43bf756

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

.changeset/moody-parts-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plextv/react-native-lightning": patch
3+
---
4+
5+
fix(scrollview): Fix issue with focusable elements inside a scrollview

packages/react-native-lightning/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@types/react-reconciler": "0.32.1"
5555
},
5656
"peerDependencies": {
57-
"@lightningjs/renderer": "^3.0.0-beta15",
57+
"@lightningjs/renderer": "3.0.0-beta15",
5858
"@plextv/react-lightning": "workspace:^",
5959
"react": "^19.2.0",
6060
"react-native": "^0.82.0"

packages/react-native-lightning/src/exports/ScrollView.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import type {
99
ScrollView as RNScrollView,
1010
ScrollViewProps as RNScrollViewProps,
1111
} from 'react-native';
12+
import { View } from 'react-native';
1213
import { createNativeSyntheticEvent } from '../utils/createNativeSyntheticEvent';
1314
import { FocusGroup } from './FocusGroup';
14-
import { Pressable } from './Pressable';
1515
import { defaultViewStyle } from './View';
1616

1717
type ScrollViewProps = RNScrollViewProps & {
@@ -201,8 +201,8 @@ export class ScrollView extends Component<ScrollViewProps, ScrollViewState> {
201201
const flexDirection = horizontal ? 'row' : 'column';
202202

203203
return (
204-
<Pressable
205-
ref={this._viewportRef}
204+
<View
205+
ref={this._setViewRef}
206206
style={[
207207
defaultViewStyle,
208208
style,
@@ -230,7 +230,7 @@ export class ScrollView extends Component<ScrollViewProps, ScrollViewState> {
230230
>
231231
{children}
232232
</FocusGroup>
233-
</Pressable>
233+
</View>
234234
);
235235
}
236236

@@ -254,6 +254,12 @@ export class ScrollView extends Component<ScrollViewProps, ScrollViewState> {
254254
);
255255
};
256256

257+
private _setViewRef = (ref: View | null) => {
258+
this._viewportRef.current = ref
259+
? (ref as unknown as LightningViewElement)
260+
: null;
261+
};
262+
257263
private _doScroll(newOffset: NativeScrollEvent) {
258264
if (
259265
newOffset &&

packages/react-native-lightning/src/plugins/reactNativePolyfillsPlugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function tryFindFocusManager(
2727
fiber as ItsFineFiber,
2828
true,
2929
(f) =>
30-
f.type?.$$typeof?.toString() === 'Symbol(react.provider)' &&
30+
(f.type?.$$typeof === Symbol.for('react.provider') ||
31+
f.type?.$$typeof === Symbol.for('react.context')) &&
3132
!!f.memoizedProps.value?.focusManager,
3233
);
3334

0 commit comments

Comments
 (0)