Skip to content

Improve handling of ListView disabled rows, and add storybook controls#3123

Merged
LFDanLu merged 20 commits intomainfrom
listview-disabled-rows
May 20, 2022
Merged

Improve handling of ListView disabled rows, and add storybook controls#3123
LFDanLu merged 20 commits intomainfrom
listview-disabled-rows

Conversation

@devongovett
Copy link
Copy Markdown
Member

@devongovett devongovett commented May 11, 2022

Reorganized the storybook for ListView to use the controls addon, and organize the stories into categories. Now mostly the stories are about data differences, and controls are used for props that could apply to any story.

Also working on some updates to the selection/navigation behavior for ListView. The new selection stories have an example with hierarchical data and breadcrumbs, which illustrates the behavior better. When an item is disabled, only selection is disabled, and not actions.

To do

  • Verify the behavior/styles
  • Tests

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@snowystinger snowystinger mentioned this pull request May 13, 2022
5 tasks
@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

…disabled-rows

# Conflicts:
#	package.json
#	packages/@react-spectrum/list/src/ListView.tsx
#	packages/@react-spectrum/list/src/ListViewItem.tsx
#	packages/@react-spectrum/list/stories/ListView.stories.tsx
#	yarn.lock
…disabled-rows

# Conflicts:
#	packages/@react-spectrum/list/stories/ListView.stories.tsx
@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

snowystinger
snowystinger previously approved these changes May 18, 2022
Copy link
Copy Markdown
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.

Problem for later probably, but in https://reactspectrum.blob.core.windows.net/reactspectrum/6db0e0700bb199c3577b53c1ba64fe1719512ee7/storybook/index.html?path=/story/listview-selection--onaction-disable-folder-selection
if I keyboard navigate into the first disabled folder, then shift tab to the breadcrumbs and go up a level, then tab back into the listview, a focus ring gets stuck on the breadcrumb root

Can any of the selection stories be crossed with drag and drop?

only odd case is still the highlight mode but only selection disabled, but I think that is what it is at this point, though should we swallow the spacebar on those elements? https://reactspectrum.blob.core.windows.net/reactspectrum/6db0e0700bb199c3577b53c1ba64fe1719512ee7/storybook/index.html?path=/story/listview-selection--disable-folder-selection&args=selectionStyle:highlight
it causes the listview to scroll

otherwise, this has my approval, tested a bit in chrome and it felt much more natural

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@devongovett devongovett marked this pull request as ready for review May 19, 2022 00:28
@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

snowystinger
snowystinger previously approved these changes May 19, 2022
(args) => render(args)
)
.add(
'value: 50',
Copy link
Copy Markdown
Collaborator

@ktabors ktabors May 19, 2022

Choose a reason for hiding this comment

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

Would we eventually want this story to work with controls or remove it since controls allow us to adjust to 50 or 100(next story)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Seems weird to have a hardcoded value of 50 in the story, but allow it to be edited in controls also?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I just edited my comment to suggest removing the hardcoded 50 and 100 stories without realizing you'd replied.

.add(
'Default',
() => render()
args => render(args)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This story used to have a value of 0, but because of the default args for the other stories it uses value=32. This default change is okay, but feels weird.

.add(
'dynamic with disabled, multiple selection, highlight',
() => (
<TableView disabledKeys={['Foo 1', 'Foo 3']} aria-label="TableView with dynamic contents" selectionStyle="highlight" selectionMode="multiple" width={300} height={200} onSelectionChange={s => onSelectionChange([...s])}>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wish there was a way to surface which keys are disabled without having to remember or check the code.

<Item textValue="Adobe Illustrator">Adobe Illustrator</Item>
<Item textValue="Adobe XD">Adobe XD</Item>
.add('dynamic items + renderEmptyState', args => (<EmptyTest {...args} />))
.add('with ActionBar', args => <ActionBarExample {...args} />)
Copy link
Copy Markdown
Collaborator

@ktabors ktabors May 20, 2022

Choose a reason for hiding this comment

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

The controls don't work with this story because ActionBarExample wasn't updated to spread them. Is that something to fix now or with the CSF 3.0 refactor? I'm noticing this is true for some other stories too.

)
)
.add(
'Drag within list (Reorder)',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm noticing the drag handler shows up after a drag. It is existing behavior.
image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think because it becomes keyboard focused (intentionally I believe), so that causes the drag handle to also appear.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is the only story I saw do this. 🤷

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd expect drag between lists to behave the same, right? It doesn't show the drag handler after a drag from one list to the other.

<Item textValue="Adobe Photoshop">Adobe Photoshop</Item>
<Item textValue="Adobe Illustrator">Adobe Illustrator</Item>
<Item textValue="Adobe XD">Adobe XD</Item>
.add('overflowMode="truncate" (default)', args => (
Copy link
Copy Markdown
Collaborator

@ktabors ktabors May 20, 2022

Choose a reason for hiding this comment

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

Shouldn't this be a control and not its own story? Maybe the story is long text values?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated. Actually this uncovered a bug that the row height doesn't update when switching between overflow modes. Maybe we can address that separately though.

Copy link
Copy Markdown
Collaborator

@ktabors ktabors left a comment

Choose a reason for hiding this comment

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

Not a fan of controls persisting state for that story. I go to another story and come back and it remembers that state. I reloaded the browser and it remembered that state. There is the reset button... maybe I'll get used to it.

@devongovett
Copy link
Copy Markdown
Member Author

Heh, I wanted the controls to persist between stories so if you set quiet then switch stories it would stay quiet. 🤷

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@ktabors
Copy link
Copy Markdown
Collaborator

ktabors commented May 20, 2022

Heh, I wanted the controls to persist between stories so if you set quiet then switch stories it would stay quiet. 🤷

I'm not seeing the persistence between stories, I'm only seeing it persisting within that story. In ListView stories, goto default, turn on quiet, goto dynamic items and it isn't quiet. Go back to default and it's still quiet.

Copy link
Copy Markdown
Collaborator

@ktabors ktabors left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, looks good!

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

Copy link
Copy Markdown
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

LGTM, will do a small fix to one of the ListView dnd stories in a followup

@LFDanLu LFDanLu merged commit d750b23 into main May 20, 2022
@LFDanLu LFDanLu deleted the listview-disabled-rows branch May 20, 2022 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants