Skip to content

Commit

Permalink
[0.68] Flatlist keyboard navigation: Mouse can move selection (facebo…
Browse files Browse the repository at this point in the history
…ok#1268)

* Flatlist keyboard navigation: Mouse can move selection (facebook#1267)

* add pull yml

* match handleOpenURLNotification event payload with iOS (facebook#755) (facebook#2)

Co-authored-by: Ryan Linton <ryanlntn@gmail.com>

* [pull] master from microsoft:master (facebook#11)

* Deprecated api (facebook#853)

* Remove deprecated/unused context param
* Update a few Mac deprecated APIs

* Packing RN dependencies, hermes and ignoring javadoc failure,  (facebook#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 (facebook#855)

* add pull yml

* match handleOpenURLNotification event payload with iOS (facebook#755) (facebook#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. (facebook#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>
  • Loading branch information
6 people authored Jul 22, 2022
1 parent 5904164 commit 7485512
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,19 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
}
}

// [TODO(macOS GH#750)
/**
* Move selection to the specified index
*
* @platform macos
*/
selectRowAtIndex(index: number) {
if (this._listRef) {
this._listRef.selectRowAtIndex(index);
}
}
// ]TODO(macOS GH#750)

/**
* Provides a handle to the underlying scroll responder.
*/
Expand Down
4 changes: 4 additions & 0 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
this.scrollToOffset({offset: newOffset});
}
}

selectRowAtIndex(rowIndex: number) {
this._selectRowAtIndex(rowIndex);
}
// ]TODO(macOS GH#774)

recordInteraction() {
Expand Down
6 changes: 5 additions & 1 deletion packages/rn-tester/js/examples/FlatList/FlatList-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type State = {|
fadingEdgeLength: number,
onPressDisabled: boolean,
textSelectable: boolean,
enableSelectionOnKeyPress: boolean, // TODO(macOS GH#774)]
enableSelectionOnKeyPress: boolean, // TODO(macOS GH#774)
|};

class FlatListExample extends React.PureComponent<Props, State> {
Expand Down Expand Up @@ -328,6 +328,10 @@ class FlatListExample extends React.PureComponent<Props, State> {
_pressItem = (key: string) => {
this._listRef && this._listRef.recordInteraction();
const index = Number(key);
// [TODO(macOS GH#774)
if (this.state.enableSelectionOnKeyPress) {
this._listRef && this._listRef.selectRowAtIndex(index);
} // ]TODO(macOS GH#774)
const itemState = pressItem(this.state.data[index]);
this.setState(state => ({
...state,
Expand Down

0 comments on commit 7485512

Please sign in to comment.