Skip to content

Conversation

@devongovett
Copy link
Member

@devongovett devongovett commented May 4, 2022

Back in #2363, we added support for onAction in selectable collections such as ListView and TableView, along with support for highlight selection. However, we have use cases for onAction (i.e. folder navigation) with checkbox selection as well. This PR enables that.

In order to implement this we made the following behavior changes:

  • When onAction is defined, row actions become the primary click interaction instead of selection.
  • Users can click the checkbox to select rows. Once at least one row is selected, clicking anywhere on another row toggles its selection state (instead of performing onAction).
  • On touch devices, users can also long press on a row to select it, just like with highlight selection.
  • With keyboards, the Enter key always performs onAction (on key up) when defined, whereas Space toggles selection (on key down).
  • When drag and drop is enabled, it may conflict with the long press gesture used to enter selection mode. To avoid this, we disable dragging when nothing is selected on touch devices. So long pressing enters selection mode, and from there the user can drag. Not sure if this is always intuitive but it might be the only way. At least it only happens when both selection and dnd are enabled.

To do before release

  • Update docs

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

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.

With VO on iPhone, I noticed that I can start dragging in two ways, either the drag handle, or the new second long press to drag that all touch devices get.
In the second case, where I long press to start dragging, none of the announcements are read about how to perform the drag and drop or when it is completed.

Disabled Key f does not look very disabled? i had to look in the story to find out why I couldn't select or drag the item (ListView draggable-rows-selectionstyle-highlight-onaction)

In TableView selectionstyle-checkbox-onaction, if I use a mouse and click and long hold, it will not do action or selection when I stop. It also briefly flashes into active mode.

checkRowSelection(rows.slice(1), false);

let checkbox = within(rows[1]).getByRole('checkbox');
userEvent.click(checkbox);
Copy link
Member

Choose a reason for hiding this comment

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

stay in pointerType touch?

onSelect(e);
}
if (hasPrimaryAction || (hasSecondaryAction && e.pointerType !== 'mouse')) {
if (e.pointerType === 'keyboard' && !isActionKey()) {
Copy link
Member

Choose a reason for hiding this comment

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

how can we have a keyboard onPress that isn't an action key?

Copy link
Member Author

Choose a reason for hiding this comment

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

Action key = Enter, Selection Key = Space

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yep, ok, weird thing then
https://reactspectrum.blob.core.windows.net/reactspectrum/b0e0b1d9f96ae8a0823015f9b74510194bb65205/storybook/index.html?path=/story/listview--selectionstyle-checkbox-onaction
If i select using space, then deselect using space. It triggers action when it deselects

Copy link
Member

Choose a reason for hiding this comment

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

+1 to what Rob saw. Something similar also happens if the user selects a row via clicking the checkbox and clicks on the row to deselect it

Copy link
Member Author

Choose a reason for hiding this comment

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

It should now only trigger onSelectionChange when de-selecting, not onAction. And when an onAction is defined, the Space key always selects, and the Enter key always only performs actions, not selection. Actions cannot be performed once in selection mode, matching mouse/touch.

@devongovett
Copy link
Member Author

@snowystinger

With VO on iPhone, I noticed that I can start dragging in two ways, either the drag handle, or the new second long press to drag that all touch devices get.
In the second case, where I long press to start dragging, none of the announcements are read about how to perform the drag and drop or when it is completed.

This is the native drag and drop API - the same as you'd use without VO on. Long press is a passthrough gesture, so VoiceOver just lets it go through to the native dnd events.

Comment on lines 790 to 792
fireEvent(el, pointerEvent('pointerdown', {pointerType: 'touch', pointerId: 1, width: 1, height: 1, pressure: 0, detail: 0}));
fireEvent(el, pointerEvent('pointerup', {pointerType: 'touch', pointerId: 1, width: 1, height: 1, pressure: 0, detail: 0}));
fireEvent.click(el, {pointerType: 'touch', width: 1, height: 1, detail: 1});
Copy link
Member

Choose a reason for hiding this comment

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

This test intentionally had a pointerType of mouse to mimic the Android Talkback specific case, mind if we change it back?

onSelect(e);
}
if (hasPrimaryAction || (hasSecondaryAction && e.pointerType !== 'mouse')) {
if (e.pointerType === 'keyboard' && !isActionKey()) {
Copy link
Member

Choose a reason for hiding this comment

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

+1 to what Rob saw. Something similar also happens if the user selects a row via clicking the checkbox and clicks on the row to deselect it

@LFDanLu
Copy link
Member

LFDanLu commented May 6, 2022

Note: I'm happy to approve and merge for Monday testing, everything else seemed to work just fine on Android/desktop

@adobe-bot
Copy link

Build successful! 🎉

Copy link
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.

Still seeing onAction get fired when the user deselects the row via click in this story but that can be followup. Approving for testing

Repro:

  1. Select the first row via clicking the checkbox
  2. De-select the row by clicking on the row itself. Note onAction is fired

@devongovett
Copy link
Member Author

Ughhhhh

@devongovett devongovett merged commit 7707ad0 into main May 9, 2022
@devongovett devongovett deleted the listview-navigation branch May 9, 2022 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants