Skip to content

Commit

Permalink
fix(select): remove label on svg chevron (#4756)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack authored and asudoh committed Nov 23, 2019
1 parent 45a8697 commit 5c6b4ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
17 changes: 0 additions & 17 deletions packages/react/src/components/Select/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,6 @@ describe('Select', () => {
expect(selectContainer.hasClass('extra-class')).toEqual(true);
});

it('has the expected default iconDescription', () => {
expect(selectWrapper().props().iconDescription).toEqual(
'open list of options'
);
});

it('adds new iconDescription when passed via props', () => {
wrapper.setProps({ iconDescription: 'new description' });
expect(wrapper.props().iconDescription).toEqual('new description');
});

it('should have iconDescription match Icon component description prop', () => {
const description = wrapper.find(ChevronDown16).props()['aria-label'];
const matches = wrapper.props().iconDescription === description;
expect(matches).toEqual(true);
});

it('should specify light select as expected', () => {
expect(selectWrapper().props().light).toEqual(false);
wrapper.setProps({ light: true });
Expand Down
18 changes: 10 additions & 8 deletions packages/react/src/components/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React from 'react';
import classNames from 'classnames';
import { settings } from 'carbon-components';
import { ChevronDown16, WarningFilled16 } from '@carbon/icons-react';
import deprecate from '../../prop-types/deprecate';

const { prefix } = settings;

Expand All @@ -21,7 +22,9 @@ const Select = React.forwardRef(function Select(
labelText,
disabled,
children,
noLabel, // reserved for use with <Pagination> component
// reserved for use with <Pagination> component
noLabel,
// eslint-disable-next-line no-unused-vars
iconDescription,
hideLabel,
invalid,
Expand Down Expand Up @@ -73,11 +76,7 @@ const Select = React.forwardRef(function Select(
ref={ref}>
{children}
</select>
<ChevronDown16
className={`${prefix}--select__arrow`}
aria-label={iconDescription}>
<title>{iconDescription}</title>
</ChevronDown16>
<ChevronDown16 className={`${prefix}--select__arrow`} />
{invalid && (
<WarningFilled16 className={`${prefix}--select__invalid-icon`} />
)}
Expand Down Expand Up @@ -167,7 +166,11 @@ Select.propTypes = {
/**
* Provide a description for the twistie icon that can be read by screen readers
*/
iconDescription: PropTypes.string.isRequired,
iconDescription: deprecate(
PropTypes.string,
'The `iconDescription` prop for `Select` is no longer needed and has ' +
'been deprecated. It will be moved in the next major release.'
),

/**
* Specify whether the label should be hidden, or not
Expand Down Expand Up @@ -205,7 +208,6 @@ Select.defaultProps = {
disabled: false,
labelText: 'Select',
inline: false,
iconDescription: 'open list of options',
invalid: false,
invalidText: '',
helperText: '',
Expand Down

0 comments on commit 5c6b4ee

Please sign in to comment.