Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-tabs] Fixed keyboard navigation for draggable tabs #1848

Merged
merged 3 commits into from
Oct 23, 2023

Conversation

saket2403
Copy link
Contributor

Summary

Fixed keyboard navigation for draggable tabs failing due to draggable props from react beautiful dnd.

What was changed:
Tab was focused programmatically to fix the issue.

Why it was changed:
Arrow Key navigation was failing because of the focus not being on the tab after mouse click.

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Reviews

In addition to engineering reviews, this PR needs:

  • UX review
  • Accessibility review
  • Functional review

Additional Details

This PR resolves:

UXPLATFORM-9761


Thank you for contributing to Terra.
@cerner/terra

@saket2403 saket2403 self-assigned this Oct 20, 2023
@github-actions github-actions bot temporarily deployed to preview-pr-1848 October 20, 2023 12:59 Destroyed
@@ -230,6 +230,10 @@ const Tab = ({
onChange(event, itemKey);
}
}
// Fix for keyboard navigation after mouse click which was failing due to draggable props.
if (isDraggable) {
event.currentTarget.focus();
Copy link
Contributor

Choose a reason for hiding this comment

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

so now the focus always remains on the dragged tab ? and once dropped the keyboard navigation starts from that position ?

Copy link
Contributor Author

@saket2403 saket2403 Oct 20, 2023

Choose a reason for hiding this comment

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

Before the change when a draggable tab was clicked, the focus was going onto the main or the body div due to the draggable props of the dnd library(exact prop/cause unknown as we spread a variable provided by the library). So I have put the focus on the clicked tab. This change has nothing to do with whether the tab has been dragged or not.

@ShettyAkarsh
Copy link
Contributor

@saket2403 does the arrow navigation works fine when the isdraggable prop is false ?

@saket2403
Copy link
Contributor Author

@saket2403 does the arrow navigation works fine when the isdraggable prop is false ?

Yes it works fine in non draggable tabs because when tab is clicked the focus is on the tab.

@saket2403 saket2403 merged commit d8f723f into main Oct 23, 2023
21 checks passed
@saket2403 saket2403 deleted the tab-dnd-arrow branch October 23, 2023 09:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants