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

ListView updates #2238

Merged
merged 20 commits into from
Aug 28, 2021
Merged

ListView updates #2238

merged 20 commits into from
Aug 28, 2021

Conversation

jluyau
Copy link
Member

@jluyau jluyau commented Aug 20, 2021

ListView:

  • better styling
  • added selection
  • added slotting for specific components (ActionGroup, ActionButton, ActionMenu, Link, Image, Icon)

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@jluyau
Copy link
Member Author

jluyau commented Aug 23, 2021

TODO:

  • update tests to test selection

<Item textValue="row1">
<Text>row 1</Text>
<Text slot="description">description for row 1</Text>
{renderActions({onPress: () => console.log('row 1')})}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we need a way to make the actions in non-folder items line up with actions in folder items? Right now, they don't because folders have the chevron. I guess we'd either always reserve space for the chevron, or somehow detect if any of the items in the list are folders and only do it then. But that might be weird if you scrolled down and loaded more items and everything shifted when a folder came in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it unreasonable to let it behave the way you say here (which is how subgrids would behave in the same circumstance) and they'd auto adjust when we detect a folder. Then have a prop that says I may have some folders where we'd reserve the space ahead of time so we don't get the shifting?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted about this with Alan, and he mentioned that if an item was a parent item, then the action buttons wouldn't line up. So, this is expected?

packages/@react-spectrum/list/stories/ListView.stories.tsx Outdated Show resolved Hide resolved
packages/@react-spectrum/list/stories/ListView.stories.tsx Outdated Show resolved Hide resolved
packages/@react-spectrum/list/src/ListViewItem.tsx Outdated Show resolved Hide resolved
packages/@react-spectrum/list/src/ListView.tsx Outdated Show resolved Hide resolved
@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@jluyau
Copy link
Member Author

jluyau commented Aug 27, 2021

Added @LFDanLu 's code for cell selection

@jluyau
Copy link
Member Author

jluyau commented Aug 27, 2021

Next listview alpha:

  • toggle/replace selection
  • highlight/checkbox
  • integrated drag support + drag icon slot
  • emphasized
  • more exact styling
  • callback (navigation) when a hasChildItems <Item> Link/chevron is clicked (?)
  • selection on touch device

@@ -2,5 +2,6 @@
"selectedCount": "{count, plural, =0 {No items selected} one {# item selected} other {# items selected}}.",
"selectedAll": "All items selected.",
"selectedItem": "{item} selected.",
"deselectedItem": "{item} not selected."
"deselectedItem": "{item} not selected.",
"select": "Select"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move over all the translations too?

@@ -74,7 +91,8 @@ function ListView<T extends object>(props: ListViewProps<T>, ref: DOMRef<HTMLDiv
}), [collection]);
let state = useGridState({
...props,
collection: gridCollection
collection: gridCollection,
allowsCellSelection: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this works... It looks like the row element is still getting aria-selected rather than the cell element, which is fine, but kinda surprising given this option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that option is just to make this block fire so we get the cell's key rather than the row's key when we do any kind of selection toggling/change. One alternative is to have a custom onAction on the row that does manager.toggleSelection(childkey) or something like that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if the cell's key is being used, then how does aria-selected end up on the row?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was playing around getting CardView working with a selection bug going from "all" to a subset of items, another possible solution is to change the types here

type: 'item',
childNodes: [{
...item,
index: 0,
type: 'cell'

to

      type: 'blah' (aka something that isn't item),
      childNodes: [{
        ...item,
        index: 0,
        type: 'item'

This means we can get rid of allowsCellSelection since the cells are now the 'item` in SelectionManager logic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devongovett sorry didn't refresh, just saw your other comment. The way aria-selected ends up in the right place is that the node provided to ListItem's useGridRow call is NOT the grid row node from the GridCollection but rather the node from ListCollection from the useListState call since we pass the ListCollection to the Virtualizer, not the GridCollection.

Those nodes from the ListCollection have matching keys with the cell because we generate the grid cells from the ListCollection:

items: [...collection].map(item => ({
type: 'item',
childNodes: [{
...item,
index: 0,
type: 'cell'
}]
}))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. Well this is fine for now, but we can test a11y and see what is better at some point.

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have the link go somewhere? I'm confused as to how parent link story should work when you press the link

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@devongovett devongovett merged commit 840ef4f into main Aug 28, 2021
@devongovett devongovett deleted the listview-alpha3 branch August 28, 2021 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants