Skip to content

Commit eefd4a8

Browse files
Saadnajmipull[bot]ryanlntnntremganandraj
authored
Flatlist keyboard navigation: Mouse can move selection (#1267)
* add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * [pull] master from microsoft:master (#11) * Deprecated api (#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (#852) * Ignore javadoc failure * Bringing few more changes from 0.63-stable * Fixing a patch in engine selection * Fixing a patch in nuget spec * Fixing the output directory of nuget pack * Packaging dependencies in the nuget * Fix onMouseEnter/onMouseLeave callbacks not firing on Pressable (#855) * add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * fix mouse evetns on pressable * delete extra yml from this branch * Add macOS tags * reorder props to have onMouseEnter/onMouseLeave always be before onPress Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> * Grammar fixes. (#856) Updates simple grammar issues. Co-authored-by: Nick Trescases <[email protected]> Co-authored-by: Anandraj <[email protected]> Co-authored-by: Saad Najmi <[email protected]> Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> Co-authored-by: Muhammad Hamza Zaman <[email protected]> * mouse selection works too * remove pull.yml Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> Co-authored-by: Nick Trescases <[email protected]> Co-authored-by: Anandraj <[email protected]> Co-authored-by: Muhammad Hamza Zaman <[email protected]>
1 parent 84c0863 commit eefd4a8

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Libraries/Lists/FlatList.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,19 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
369369
}
370370
}
371371

372+
// [TODO(macOS GH#750)
373+
/**
374+
* Move selection to the specified index
375+
*
376+
* @platform ios
377+
*/
378+
selectRowAtIndex(index: number) {
379+
if (this._listRef) {
380+
this._listRef.selectRowAtIndex(index);
381+
}
382+
}
383+
// ]TODO(macOS GH#750)
384+
372385
/**
373386
* Provides a handle to the underlying scroll responder.
374387
*/

Libraries/Lists/VirtualizedList.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
592592
this.scrollToOffset({offset: newOffset});
593593
}
594594
}
595+
596+
selectRowAtIndex(rowIndex: number) {
597+
this._selectRowAtIndex(rowIndex);
598+
}
595599
// ]TODO(macOS GH#774)
596600

597601
recordInteraction() {

packages/rn-tester/js/examples/FlatList/FlatList-basic.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type State = {|
6363
fadingEdgeLength: number,
6464
onPressDisabled: boolean,
6565
textSelectable: boolean,
66-
enableSelectionOnKeyPress: boolean, // TODO(macOS GH#774)]
66+
enableSelectionOnKeyPress: boolean, // TODO(macOS GH#774)
6767
|};
6868

6969
class FlatListExample extends React.PureComponent<Props, State> {
@@ -329,6 +329,10 @@ class FlatListExample extends React.PureComponent<Props, State> {
329329
_pressItem = (key: string) => {
330330
this._listRef && this._listRef.recordInteraction();
331331
const index = Number(key);
332+
// [TODO(macOS GH#774)
333+
if (this.state.enableSelectionOnKeyPress) {
334+
this._listRef && this._listRef.selectRowAtIndex(index);
335+
} // ]TODO(macOS GH#774)
332336
const itemState = pressItem(this.state.data[index]);
333337
this.setState(state => ({
334338
...state,

0 commit comments

Comments
 (0)