-
Notifications
You must be signed in to change notification settings - Fork 138
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
Keyboard navigation in Flatlist #1258
Conversation
[pull] master from microsoft:master
#2) Co-authored-by: Ryan Linton <[email protected]>
[pull] master from microsoft:master
[pull] master from microsoft:master
* Deprecated api (microsoft#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (microsoft#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 (microsoft#855) * add pull yml * match handleOpenURLNotification event payload with iOS (microsoft#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. (microsoft#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]>
@chiuam will respond to both comments here
Yes, I think it scrolls into the last "realized" (aka, kept in memory) cell. By default, Flatlist keeps a "page" of views at the top and bottom of the list, along with your current viewport + a page above and below. This demo I think might actually be an infinite list, so it scrolls to the bottom of what is initially loaded. If you scroll down more, you will load more views, and then you can opt+down to the new "bottom" (199 for me). This isn't perfect, but I'm not sure how to handle infinite lists better. It seems that NSOutlineView in Xcode also does the same thing. See this Xcode project with a lot of errors. The first Opt+Down doesn't go to the bottom. It has to load in more errors, and then a second Opt+Down takes it to the bottom. Screen.Recording.2022-07-18.at.10.48.35.AM.mov
Yes, I made it so that no keyboard items are selected if There's a few things I can do to help make this more clear:
See an example of both those elements in this preferences pane table view Screen.Recording.2022-07-18.at.11.01.36.AM.movNote that to get the full proper keyboarding behavior, you do need to wrap the Flatlist in a FocusZone. I couldn't get that working because I couldn't figure out how to side load my local RN-macOS changes into FURN easily to test =/. I can give it another go this week though. |
With the latest changes, see video below. I couldn't get the Screen.Recording.2022-07-18.at.4.41.55.PM.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
* add pull yml * match handleOpenURLNotification event payload with iOS (microsoft#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * [pull] master from microsoft:master (#11) * Deprecated api (microsoft#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (microsoft#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 (microsoft#855) * add pull yml * match handleOpenURLNotification event payload with iOS (microsoft#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. (microsoft#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]> * wip * wip * more wip * Home/End/OptionUp/OptionDown work * ensureItemAtIndexIsVisible works * Home/End work * Initial cleanup for PR * More cleanup * More cleanup * Make it a real prop * No need for client code * Don't move keyboard focus with selection * Update tags * Fix flow errors * Update colors, make ScrollView focusable * prettier * undo change * Fix flow errors * Clean up code + handle page up/down with new prop 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]>
* add pull yml * match handleOpenURLNotification event payload with iOS (microsoft#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * [pull] master from microsoft:master (#11) * Deprecated api (microsoft#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (microsoft#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 (microsoft#855) * add pull yml * match handleOpenURLNotification event payload with iOS (microsoft#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. (microsoft#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]> * wip * wip * more wip * Home/End/OptionUp/OptionDown work * ensureItemAtIndexIsVisible works * Home/End work * Initial cleanup for PR * More cleanup * More cleanup * Make it a real prop * No need for client code * Don't move keyboard focus with selection * Update tags * Fix flow errors * Update colors, make ScrollView focusable * prettier * undo change * Fix flow errors * Clean up code + handle page up/down with new prop 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]>
* Keyboard navigation in Flatlist (#1258) * 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]> * wip * wip * more wip * Home/End/OptionUp/OptionDown work * ensureItemAtIndexIsVisible works * Home/End work * Initial cleanup for PR * More cleanup * More cleanup * Make it a real prop * No need for client code * Don't move keyboard focus with selection * Update tags * Fix flow errors * Update colors, make ScrollView focusable * prettier * undo change * Fix flow errors * Clean up code + handle page up/down with new prop 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]> * yarn lint --fix 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]>
* Keyboard navigation in Flatlist (#1258) * 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]> * wip * wip * more wip * Home/End/OptionUp/OptionDown work * ensureItemAtIndexIsVisible works * Home/End work * Initial cleanup for PR * More cleanup * More cleanup * Make it a real prop * No need for client code * Don't move keyboard focus with selection * Update tags * Fix flow errors * Update colors, make ScrollView focusable * prettier * undo change * Fix flow errors * Clean up code + handle page up/down with new prop 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]> * yarn lint --fix 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]>
* Keyboard navigation in Flatlist (#1258) * 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]> * wip * wip * more wip * Home/End/OptionUp/OptionDown work * ensureItemAtIndexIsVisible works * Home/End work * Initial cleanup for PR * More cleanup * More cleanup * Make it a real prop * No need for client code * Don't move keyboard focus with selection * Update tags * Fix flow errors * Update colors, make ScrollView focusable * prettier * undo change * Fix flow errors * Clean up code + handle page up/down with new prop 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]> * 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]> * Update FlatList.js 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]>
* add pull yml * match handleOpenURLNotification event payload with iOS (microsoft#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * [pull] master from microsoft:master (#11) * Deprecated api (microsoft#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (microsoft#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 (microsoft#855) * add pull yml * match handleOpenURLNotification event payload with iOS (microsoft#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. (microsoft#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]> * wip * wip * more wip * Home/End/OptionUp/OptionDown work * ensureItemAtIndexIsVisible works * Home/End work * Initial cleanup for PR * More cleanup * More cleanup * Make it a real prop * No need for client code * Don't move keyboard focus with selection * Update tags * Fix flow errors * Update colors, make ScrollView focusable * prettier * undo change * Fix flow errors * Clean up code + handle page up/down with new prop 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]>
Please select one of the following
Summary
This PR lights up the Flatlist prop
enableSelectionOnKeyPress
that allows one to use arrow keys to move selection between Flatlist cells. The functionality is opt-in.We want Flatlist to behave like NSTableView does on macOS. That means:
This would normally involve a lot of new custom keyboard events for Flatlist. Luckily, it seems my predecessors already wrote most of the code for this in the form of the
enableSelectionOnKeyPress
prop. This is a macOS only prop that basically did (2). The code path was broken, so this functionality never actually worked.This PR fixes the logic so that
enableSelectionOnKeyPress
works again, along with adding extra handling for (4) and (5), Home/End/Option+Up/Option+Down. This PR does not address (1). I couldn't find a simple way to handle focus like NSTableView without sticking a FocusZone inside Flatlist. I'll leave that as a responsibility of the developer.Caveats:
Note that "Selection is slightly different than keyboard focus on macOS, due to legacy reasons involving NSCells. As far as I can tell, NSTableView takes (and keeps) focus while arrow keys change which row you can interact with. Why don't we move focus with selection, i.e: the selected row gets keyboard focus? It causes issues, as the "Tab" key isn't handled properly. For an NSTableView, "Tab" would move keyboard focus from the table view to the next control in the key view loop. For Flatlist with the new prop, "Tab" moves keyboard focus to the next row. This is undesirable behavior :/. A solution would be to put a FocusZone around the Flatlist... which might be something we explore in the future.
Per this Reconcile Keyboarding APIs in React Native proposal, we're supposed to deprecate onScrollKeyDown. But this new functionality uses it, and depends on its' existence. The day we align with the keyboarding API in React Native Windows, this whole change will need to be revisited.
Changelog
[macOS] [Fixed] - enable arrow key navigation in Flatlist
Test Plan
I added a new switch to the Flatlist example named "Keyboard Navigation" to set the prop. Since the prop is opt-in (false by default), existing users of Flatlist should not be affected.
Screen.Recording.2022-07-16.at.8.25.18.PM.mov