-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: support Textfields and other interactive components in Table #10159
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
Open
LFDanLu
wants to merge
32
commits into
main
Choose a base branch
from
textfield_gridlists
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,677
−105
Open
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
8b71adf
initial changes to support textfields in gridlists
LFDanLu f491a18
use robs event leak type select and prevent space from triggering sel…
LFDanLu 8fd5392
fix tests, but also use a more robust check instead of active element
LFDanLu 10beb03
add S2 Card story and tests for tree and gridlist
LFDanLu 5dfa72f
make presses on components in rows not trigger selection
LFDanLu 0aecbf1
add docs for rac
LFDanLu 4c35292
update docs and dedupe tree logic in useGridListItem keyboard handlers
LFDanLu 40fe024
Merge branch 'main' of github.com:adobe/react-spectrum into textfield…
LFDanLu 4e8d6f5
create stories for table with textfields
LFDanLu dde69eb
support textfields in tables
LFDanLu 8ea84d4
add tests
LFDanLu fd92d8f
add table docs and update copy
LFDanLu d5261df
fix missing s2 table columnheader focus ring and add focus ring to th…
LFDanLu ef47186
formatting
LFDanLu 9570eb4
make editable table edit buttons focusable via tab when using tab key…
LFDanLu 52f8707
Merge branch 'main' of github.com:adobe/react-spectrum into textfield…
LFDanLu 63114f1
clean up uneeded code and mirror useGridListItem more closely
LFDanLu 9318022
add focusMode to Cell, make S2 TableView auto focus selection checkbo…
LFDanLu 9edd140
Merge branch 'main' into textfield_gridlists
LFDanLu 2558dd3
add focusMode to gridListItem
LFDanLu f58f627
Merge branch 'textfield_gridlists' of github.com:adobe/react-spectrum…
LFDanLu 0d6d429
add allowsArrowNavigation so arrow key navigation can be triggered ev…
LFDanLu 9bd8d76
add allowsArrowNavigation and focusMode to tree, tests, and docs updates
LFDanLu d954118
add docs for focusMode/allowsArrowNavigation
LFDanLu babfeb4
move press selection prevention logic into useSelectableItem
LFDanLu 06b5308
fix case where click on cell didnt trigger row selection
LFDanLu 7da4f02
fix case with nested collections and other review comments
LFDanLu f7e7e3e
clean up tests so it uses one table implementation
LFDanLu 1bdd6e0
Merge branch 'main' of github.com:adobe/react-spectrum into textfield…
LFDanLu f156d28
make sure shift tabbing from a child of a cell doesnt move focus back…
LFDanLu ab75b15
add coverage tests
LFDanLu 34e52a9
fix lint
LFDanLu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -732,7 +732,7 @@ let photos = [ | |
| items={photos} | ||
| selectionMode="multiple" | ||
| aria-label="Shared files"> | ||
| {item => ( | ||
| {item => ( | ||
| <GridListItem textValue={item.title}> | ||
| <img src={item.src} alt="" /> | ||
| <Text> | ||
|
|
@@ -744,6 +744,58 @@ let photos = [ | |
| </GridList> | ||
| ``` | ||
|
|
||
| You can further control if a row automatically focuses itself or its children on keyboard focus via `focusMode`. Futhermore, `allowsArrowNavigation` can be used to allow arrow key navigation from the row's children to adjacent rows. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. feed back on the example here welcome, didn't want to make something too complicated haha. Also wasn't quite sure what a realistic example for Tree would be, so I skipped adding docs for that |
||
| This allows keyboard users to navigate to the contents of the row without needing to tab in and out of the row even when in tab keyboard navigation. | ||
| Be sure to only set `allowsArrowNavigation` on rows whose interactive content don't use arrow keys. | ||
|
|
||
| ```tsx render | ||
| "use client"; | ||
| import {GridList, GridListItem, Text} from 'vanilla-starter/GridList'; | ||
| import {Button} from 'vanilla-starter/Button'; | ||
| import {useState} from 'react'; | ||
|
|
||
| ///- begin collapse -/// | ||
| let initialItems = [ | ||
| {id: 1, name: 'Apple', image: 'https://images.unsplash.com/photo-1630563451961-ac2ff27616ab?q=80&w=400&auto=format&fit=crop&ixlib=rb-4.1.0'}, | ||
| {id: 2, name: 'Peach', image: 'https://images.unsplash.com/photo-1642372849486-f88b963cb734?q=80&w=400&auto=format&fit=crop&ixlib=rb-4.1.0'}, | ||
| {id: 3, name: 'Blueberry', image: 'https://images.unsplash.com/photo-1606757389667-45c2024f9fa4?q=80&w=400&auto=format&fit=crop&ixlib=rb-4.1.0'}, | ||
| {id: 4, name: 'Broccoli', image: 'https://images.unsplash.com/photo-1685504445355-0e7bdf90d415?q=80&w=400&auto=format&fit=crop&ixlib=rb-4.1.0'}, | ||
| {id: 5, name: 'Brussels Sprouts', image: 'https://images.unsplash.com/photo-1685504507286-dc290728c01a?q=80&w=400&auto=format&fit=crop&ixlib=rb-4.1.0'}, | ||
| {id: 6, name: 'Peas', image: 'https://images.unsplash.com/photo-1587411768345-867e228218c8?q=80&w=400&auto=format&fit=crop&ixlib=rb-4.1.0'}, | ||
| ]; | ||
| ///- end collapse -/// | ||
|
|
||
| function Example() { | ||
| let [items, setItems] = useState(initialItems); | ||
| return ( | ||
| <GridList | ||
| items={items} | ||
| layout="stack" | ||
| orientation="vertical" | ||
| keyboardNavigationBehavior="tab" | ||
| aria-label="Shopping cart"> | ||
| {item => ( | ||
| <GridListItem | ||
| /*- begin highlight -*/ | ||
| focusMode="child" | ||
| allowsArrowNavigation | ||
| /*- end highlight -*/ | ||
| textValue={item.name}> | ||
| <img src={item.image} width={60} height={60} alt="" /> | ||
| <Text>{item.name}</Text> | ||
| <Button | ||
| style={{width: 150, marginInlineStart: 10}} | ||
| variant="secondary" | ||
| onPress={() => setItems(prev => prev.filter(i => i.id !== item.id))}> | ||
| Remove from cart | ||
| </Button> | ||
| </GridListItem> | ||
| )} | ||
| </GridList> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ## Drag and drop | ||
|
|
||
| GridList supports drag and drop interactions when the `dragAndDropHooks` prop is provided using the <TypeLink links={docs.links} type={docs.exports.useDragAndDrop} /> hook. Users can drop data on the list as a whole, on individual items, insert new items between existing ones, or reorder items. React Aria supports drag and drop via mouse, touch, keyboard, and screen reader interactions. See the [drag and drop guide](dnd?component=GridList) to learn more. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
do we need to police this? what happens if this is ignored?
Uh oh!
There was an error while loading. Please reload this page.
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.
I guess it partially depends on our stance around if we want to expose this in S2 or just in RAC. I'm currently leaning towards exposing these in S2 but not policing it since it falls into the realm of user error rather an accessibility problem IMO
I'm also not 100% tied to exposing these props in S2, I'm not sure what use cases may exist that S2 end users would have so maybe it would best to wait for requests to expose these props.
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.
chatted in otters about this, we are ok exposing these for now