Skip to content

Commit 7485512

Browse files
Saadnajmipull[bot]ryanlntnntremganandraj
authored
[0.68] Flatlist keyboard navigation: Mouse can move selection (#1268)
* Flatlist keyboard navigation: Mouse can move selection (#1267) * add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton <ryanlntn@gmail.com> * [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 <ryanlntn@gmail.com> * 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 <ryanlntn@gmail.com> * Grammar fixes. (#856) Updates simple grammar issues. Co-authored-by: Nick Trescases <42704557+ntre@users.noreply.github.com> Co-authored-by: Anandraj <anandrag@microsoft.com> Co-authored-by: Saad Najmi <saadnajmi2@gmail.com> Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <ryanlntn@gmail.com> Co-authored-by: Muhammad Hamza Zaman <mh.zaman.4069@gmail.com> * mouse selection works too * remove pull.yml Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <ryanlntn@gmail.com> Co-authored-by: Nick Trescases <42704557+ntre@users.noreply.github.com> Co-authored-by: Anandraj <anandrag@microsoft.com> Co-authored-by: Muhammad Hamza Zaman <mh.zaman.4069@gmail.com> * Update FlatList.js Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <ryanlntn@gmail.com> Co-authored-by: Nick Trescases <42704557+ntre@users.noreply.github.com> Co-authored-by: Anandraj <anandrag@microsoft.com> Co-authored-by: Muhammad Hamza Zaman <mh.zaman.4069@gmail.com>
1 parent 5904164 commit 7485512

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 macos
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> {
@@ -328,6 +328,10 @@ class FlatListExample extends React.PureComponent<Props, State> {
328328
_pressItem = (key: string) => {
329329
this._listRef && this._listRef.recordInteraction();
330330
const index = Number(key);
331+
// [TODO(macOS GH#774)
332+
if (this.state.enableSelectionOnKeyPress) {
333+
this._listRef && this._listRef.selectRowAtIndex(index);
334+
} // ]TODO(macOS GH#774)
331335
const itemState = pressItem(this.state.data[index]);
332336
this.setState(state => ({
333337
...state,

0 commit comments

Comments
 (0)