Skip to content

Stop propagation when pressing Enter on a native link#3380

Merged
devongovett merged 1 commit into
mainfrom
link-press-keyboard
Aug 5, 2022
Merged

Stop propagation when pressing Enter on a native link#3380
devongovett merged 1 commit into
mainfrom
link-press-keyboard

Conversation

@devongovett
Copy link
Copy Markdown
Member

@devongovett devongovett commented Aug 4, 2022

Closes #2599. Closes #2619.

Slightly different version of the fix in #2619 (test and partial fix reused). This fixes scrolling and selection when pressing Space when focused on a link in a TableView, while letting Enter trigger the link natively. Two fixes:

  1. Use currentTarget rather than target to check whether to handle a keyboard event. This ensures the check for link handling doesn't apply when the table row is handling an event that propagated up from a link (e.g. Space key). This is the same as in fix(#2599): TableView: space key on link within cell scrolls the TableView down a page #2619.
  2. Stop propagation on native HTML links during keydown, even when we don't otherwise handle the event, because the browser will handle it natively and we don't want TableView to also handle it. This is different from fix(#2599): TableView: space key on link within cell scrolls the TableView down a page #2619 in that the link handles it rather than the table. I think we should stop propagation here because the event is handled (by the browser), so elements above it should not handle it as well.

📝 Test Instructions:

  1. Open TableView async loading story.
  2. Move focus to a link in the table.
  3. Press Space key. Selection of the table row should be toggled, and it should not scroll.
  4. Press Enter on the link. It should open in a new tab.

@adobe-bot
Copy link
Copy Markdown

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

@majornista
Copy link
Copy Markdown
Collaborator

Thanks for this. LGTM

@devongovett devongovett merged commit 9498c7d into main Aug 5, 2022
@devongovett devongovett deleted the link-press-keyboard branch August 5, 2022 00:44
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.

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

5 participants