Skip to content

Commit

Permalink
fix(storefront): BCTHEME-447 extend keyboard support for radio buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-alexsaiannyi committed Apr 2, 2021
1 parent dc9d19e commit ff92824
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

## Draft

- Added keyboard support on radio buttons. [#2028](https://github.com/bigcommerce/cornerstone/pull/2028)
## 5.3.0 (03-25-2021)
- Remove AddThis for social sharing, replace with provider sharing links. [#1997](https://github.com/bigcommerce/cornerstone/pull/1997)
- IE11 - Clicking on Search Does Not Display Search Bar. [#2017](https://github.com/bigcommerce/cornerstone/pull/2017)
Expand Down
3 changes: 3 additions & 0 deletions assets/js/theme/common/aria/radioOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const setCheckedRadioItem = (itemCollection, itemIdx) => {
}

$item.attr('aria-checked', true).prop('checked', true).focus();
$item.trigger('change');
});
};

Expand Down Expand Up @@ -40,12 +41,14 @@ const handleItemKeyDown = itemCollection => e => {
case ariaKeyCodes.UP: {
const prevItemIdx = calculateTargetItemPosition(lastCollectionItemIdx, itemIdx - 1);
itemCollection.get(prevItemIdx).focus();
setCheckedRadioItem(itemCollection, itemIdx - 1);
break;
}
case ariaKeyCodes.RIGHT:
case ariaKeyCodes.DOWN: {
const nextItemIdx = calculateTargetItemPosition(lastCollectionItemIdx, itemIdx + 1);
itemCollection.get(nextItemIdx).focus();
setCheckedRadioItem(itemCollection, itemIdx + 1);
break;
}

Expand Down

0 comments on commit ff92824

Please sign in to comment.