Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(multiselect): replace checkbox with visually identical element #5039

Merged
merged 10 commits into from
Jan 24, 2020
28 changes: 16 additions & 12 deletions packages/react/src/components/MultiSelect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import isEqual from 'lodash.isequal';
import { settings } from 'carbon-components';
import { WarningFilled16 } from '@carbon/icons-react';
import ListBox, { PropTypes as ListBoxPropTypes } from '../ListBox';
import Checkbox from '../Checkbox';
import Selection from '../../internal/Selection';
import { sortingPropTypes } from './MultiSelectPropTypes';
import { defaultItemToString } from './tools/itemToString';
Expand Down Expand Up @@ -357,7 +356,10 @@ export default class MultiSelect extends React.Component {
/>
</ListBox.Field>
{isOpen && (
<ListBox.Menu aria-labelledby={`${labelId}`} id={id}>
<ListBox.Menu
aria-multiselectable="true"
aria-labelledby={`${labelId}`}
id={id}>
{sortItems(items, {
selectedItems: {
top: selectedItems,
Expand All @@ -378,19 +380,21 @@ export default class MultiSelect extends React.Component {
<ListBox.MenuItem
key={itemProps.id}
isActive={isChecked}
role="option"
aria-selected={isChecked}
tabIndex={-1}
isHighlighted={highlightedIndex === index}
title={itemText}
{...itemProps}>
<Checkbox
id={`${itemProps.id}__checkbox`}
title={useTitleInItem ? itemText : null}
name={itemText}
checked={isChecked}
disabled={disabled}
readOnly={true}
tabIndex="-1"
labelText={itemText}
/>
<div className={`${prefix}--checkbox-wrapper`}>
<span
title={useTitleInItem ? itemText : null}
className={`${prefix}--checkbox-label`}
data-contained-checkbox-state={isChecked}
id={`${itemProps.id}__checkbox`}>
{itemText}
</span>
</div>
</ListBox.MenuItem>
);
})}
Expand Down