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

Commit

Permalink
[terra-tabs] Fixed keyboard navigation for draggable tabs (#1848)
Browse files Browse the repository at this point in the history
  • Loading branch information
saket2403 authored Oct 23, 2023
1 parent 3b96f4c commit d8f723f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/terra-tabs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

* Fixed
* Fixed keyboard navigation after mouse click for draggable tabs.

## Unreleased

## 7.11.0 - (October 20, 2023)
Expand Down
4 changes: 4 additions & 0 deletions packages/terra-tabs/src/common-tabs/_Tab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
attributes.tabIndex = isSelected ? 0 : -1;
attributes.onClick = onClick;
Expand Down
5 changes: 5 additions & 0 deletions packages/terra-tabs/tests/wdio/tabs-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ Terra.describeViewports('Tabs - Drag and Drop', ['medium'], () => {
browser.keys(['Tab', 'Tab', 'Space', 'ArrowRight', 'Space']);
Terra.validates.element('After Drag and Drop', { selector: '#root' });
});
it('should navigate with keyboard after mouse click', () => {
$('#controlledTabs-Radiology').click();
browser.keys(['ArrowRight']);
expect($('#controlledTabs-Cardiology')).toBeFocused();
});
});

Terra.describeViewports('Tabs - Add and Close', ['medium'], () => {
Expand Down

0 comments on commit d8f723f

Please sign in to comment.