Skip to content

fix(#2599): TableView: space key on link within cell scrolls the TableView down a page#2619

Closed
majornista wants to merge 25 commits into
mainfrom
Issue-2599-TableView-scroll-on-space-key
Closed

fix(#2599): TableView: space key on link within cell scrolls the TableView down a page#2619
majornista wants to merge 25 commits into
mainfrom
Issue-2599-TableView-scroll-on-space-key

Conversation

@majornista
Copy link
Copy Markdown
Collaborator

@majornista majornista commented Nov 30, 2021

Closes #2599

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue 2559.
  • 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:

  1. Open https://reactspectrum.blob.core.windows.net/reactspectrum/903179155a85c47707c9bfb6902e0deef1b7d892/storybook/index.html?path=/story/tableview--async-loading
  2. Tab to move focus to the first article link in the first row within the table body.
  3. Press Space key.
  4. Since this is a link, Space shouldn't activate the link, but the event should bubble to be handled by the table row, toggling selection. preventDefault should be called on the event to prevent the TableView from scrolling.

🧢 Your Project:

Adobe/Accessibility

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@majornista majornista requested a review from dkario December 2, 2021 22:14
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.

I tested the table with the link and it worked. Nervous about this causing regressions.

Comment thread packages/@react-spectrum/table/test/Table.test.js
Comment thread packages/@react-aria/interactions/src/usePress.ts Outdated
Comment thread packages/@react-aria/interactions/src/usePress.ts Outdated
1. update Table test to better evaluate preventDefault of scrolling.
2. add `isLinkRole` utility method to `usePress`.
@majornista majornista requested a review from ktabors December 3, 2021 21:16
@adobe-bot

This comment was marked as outdated.

dkario
dkario previously approved these changes Dec 6, 2021
Copy link
Copy Markdown
Contributor

@dkario dkario left a comment

Choose a reason for hiding this comment

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

The code looks good. I defer to RSP teammates on potential regressions

ktabors
ktabors previously approved these changes Dec 10, 2021
@adobe-bot

This comment was marked as outdated.

@devongovett
Copy link
Copy Markdown
Member

This is a bit more changes than I was hoping. Should we perhaps use e.currentTarget in isValidKeyboardEvent rather than e.target? I think the problem is that the usePress on the link correctly ignores the event, but the table row also ignores it when it shouldn't due to the target still being the link. If we used currentTarget, this would not happen because the target would be the row element. currentTarget wouldn't work for the global keyup listener that we have, so perhaps pass the target in as an argument to isValidKeyboardEvent and use state.target in that case.

@majornista
Copy link
Copy Markdown
Collaborator Author

majornista commented Dec 23, 2021

This is a bit more changes than I was hoping. Should we perhaps use e.currentTarget in isValidKeyboardEvent rather than e.target? I think the problem is that the usePress on the link correctly ignores the event, but the table row also ignores it when it shouldn't due to the target still being the link. If we used currentTarget, this would not happen because the target would be the row element. currentTarget wouldn't work for the global keyup listener that we have, so perhaps pass the target in as an argument to isValidKeyboardEvent and use state.target in that case.

currentTarget doesn’t exist on the nativeEvent when the keyboard event fires from the link.

@majornista majornista dismissed stale reviews from ktabors and dkario via 6200f33 December 23, 2021 18:26
@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@majornista
Copy link
Copy Markdown
Collaborator Author

majornista commented Jan 27, 2022

This is a bit more changes than I was hoping. Should we perhaps use e.currentTarget in isValidKeyboardEvent rather than e.target? I think the problem is that the usePress on the link correctly ignores the event, but the table row also ignores it when it shouldn't due to the target still being the link. If we used currentTarget, this would not happen because the target would be the row element. currentTarget wouldn't work for the global keyup listener that we have, so perhaps pass the target in as an argument to isValidKeyboardEvent and use state.target in that case.

@devongovett See 44909d5, which I think consolidates the logic for a link within an ancestor that also handles the space key to trigger a usePress into isValidKeyboardEvent.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot

This comment was marked as outdated.

@adobe-bot
Copy link
Copy Markdown

@adobe-bot
Copy link
Copy Markdown

@adobe-bot
Copy link
Copy Markdown

@adobe-bot
Copy link
Copy Markdown

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.

TableView: space key on link within cell scrolls the TableView down a page

5 participants