Skip to content

Commit

Permalink
fix(ListChoice): disabled items should not get focus (#2474)
Browse files Browse the repository at this point in the history
Co-authored-by: Luděk Vepřek <weprous@gmail.com>
  • Loading branch information
mainframev and vepor committed Nov 10, 2020
1 parent f092fa9 commit 08eb9c4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/orbit-components/src/ListChoice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ StyledListChoiceContent.defaultProps = {
theme: defaultTheme,
};

const ListChoice = (props: Props) => {
const { dataTest, icon, title, description, selectable, onClick, selected, disabled } = props;
const ListChoice = ({
dataTest,
icon,
title,
description,
selectable,
onClick,
selected,
disabled,
}: Props) => {
const conditionalProps = {
...(selectable ? { "aria-checked": selected } : null),
};
Expand All @@ -92,7 +100,7 @@ const ListChoice = (props: Props) => {
onClick={!disabled ? onClick : null}
data-test={dataTest}
onKeyDown={!disabled ? handleKeyDown(onClick) : null}
tabIndex="0"
tabIndex={disabled ? "-1" : "0"}
disabled={disabled}
aria-disabled={disabled}
role={selectable ? "checkbox" : "button"}
Expand Down

0 comments on commit 08eb9c4

Please sign in to comment.