Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatlist keyboard navigation: Mouse can move selection #1267

Merged
merged 29 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c2b2e2f
add pull yml
Saadnajmi Mar 22, 2021
ab88c7d
Merge pull request #1 from microsoft/master
Saadnajmi Apr 2, 2021
7a9006b
match handleOpenURLNotification event payload with iOS (#755) (#2)
pull[bot] Apr 21, 2021
497aa72
Merge pull request #3 from microsoft/master
Saadnajmi Apr 28, 2021
1c81e5b
Merge pull request #4 from microsoft/master
Saadnajmi May 6, 2021
28aed35
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi May 20, 2021
62dc473
Merge branch 'master' of github.com:Saadnajmi/react-native-macos
Saadnajmi May 20, 2021
93c7296
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi May 21, 2021
780b2b7
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Jun 11, 2021
99d5182
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Aug 22, 2021
09e872d
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Sep 3, 2021
9a25530
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Oct 6, 2021
d82a01b
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Oct 12, 2021
d9faa3a
[pull] master from microsoft:master (#11)
pull[bot] Oct 14, 2021
39bd488
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Oct 21, 2021
c583ed3
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Oct 25, 2021
9cea270
Merge branch 'master' of github.com:Saadnajmi/react-native-macos
Saadnajmi Nov 7, 2021
7571092
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Nov 7, 2021
2153ef5
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Dec 8, 2021
47ee4ab
Merge branch 'microsoft:master' into master
Saadnajmi Jan 3, 2022
c74bf4d
Merge branch 'microsoft:main' into main
Saadnajmi Jan 30, 2022
5f905ef
Merge branch 'microsoft:main' into main
Saadnajmi Feb 24, 2022
2869642
Merge branch 'microsoft:main' into main
Saadnajmi Mar 7, 2022
b97b271
Merge branch 'microsoft:main' into main
Saadnajmi Apr 23, 2022
199621a
Merge branch 'main' of github.com:microsoft/react-native-macos
Saadnajmi Apr 29, 2022
5ec261f
Merge branch 'microsoft:main' into main
Saadnajmi Jun 20, 2022
81ef374
Merge branch 'main' of github.com:microsoft/react-native-macos
Saadnajmi Jul 21, 2022
00566cc
mouse selection works too
Saadnajmi Jul 21, 2022
870314f
remove pull.yml
Saadnajmi Jul 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ios
*/
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 @@ -329,6 +329,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