diff --git a/.changeset/native-dataview-keyboard.md b/.changeset/native-dataview-keyboard.md new file mode 100644 index 0000000..3909577 --- /dev/null +++ b/.changeset/native-dataview-keyboard.md @@ -0,0 +1,6 @@ +--- +'@wirecore/wirelayer-native': patch +--- + +DataView: in the browser (react-native-web) the scrolling list takes the keyboard focus, so the arrow keys scroll it even +when the items have no controls. diff --git a/packages/native/src/components/DataView/DataView.tsx b/packages/native/src/components/DataView/DataView.tsx index c1342da..bbedfbd 100644 --- a/packages/native/src/components/DataView/DataView.tsx +++ b/packages/native/src/components/DataView/DataView.tsx @@ -8,7 +8,7 @@ import { } from '@wirecore/wirelayer-recipes/native'; import { LayoutGrid, List } from 'lucide-react-native'; import { useEffect, useRef, useState, type ReactNode } from 'react'; -import { FlatList, Text, View, type StyleProp, type ViewStyle } from 'react-native'; +import { FlatList, Platform, Text, View, type StyleProp, type ViewStyle } from 'react-native'; import { useLocale } from '../../locale.js'; import { useAnnouncer } from '../../utils/announce.js'; import { useControllable } from '../../utils/useControllable.js'; @@ -251,6 +251,9 @@ export function DataView({ role="list" aria-label={label} aria-busy={firstLoad || (announces && busy) || undefined} + // In the browser (react-native-web) the list takes the keyboard focus, so the arrow keys scroll it even + // when the items have no controls + focusable={Platform.OS === 'web'} contentContainerClassName={styles.content()} onEndReached={infinite && autoLoad && !firstLoad ? onEnd : undefined} onEndReachedThreshold={0.5}