Merge pull request woocommerce/woocommerce-admin#512 from woocommerce/fix/Tag-remove-label

Tag: use label in removeLabel
This commit is contained in:
Paul Sealock 2018-10-15 15:44:50 +13:00 committed by GitHub
commit d994d22c5d
2 changed files with 2 additions and 12 deletions

View File

@ -95,7 +95,6 @@ class Search extends Component {
id={ item.id } id={ item.id }
label={ item.label } label={ item.label }
remove={ this.removeResult } remove={ this.removeResult }
removeLabel={ __( 'Remove product', 'wc-admin' ) }
screenReaderLabel={ screenReaderLabel } screenReaderLabel={ screenReaderLabel }
/> />
); );

View File

@ -2,7 +2,7 @@
/** /**
* External dependencies * External dependencies
*/ */
import { __ } from '@wordpress/i18n'; import { __, sprintf } from '@wordpress/i18n';
import { Fragment } from '@wordpress/element'; import { Fragment } from '@wordpress/element';
import classnames from 'classnames'; import classnames from 'classnames';
import { Button, Dashicon, IconButton, Popover } from '@wordpress/components'; import { Button, Dashicon, IconButton, Popover } from '@wordpress/components';
@ -27,7 +27,6 @@ const Tag = ( {
label, label,
popoverContents, popoverContents,
remove, remove,
removeLabel,
screenReaderLabel, screenReaderLabel,
setState, setState,
className, className,
@ -76,7 +75,7 @@ const Tag = ( {
className="woocommerce-tag__remove" className="woocommerce-tag__remove"
icon={ <Dashicon icon="dismiss" size={ 20 } /> } icon={ <Dashicon icon="dismiss" size={ 20 } /> }
onClick={ remove( id ) } onClick={ remove( id ) }
label={ removeLabel } label={ sprintf( __( 'Remove %s', 'wc-admin' ), label ) }
aria-describedby={ labelId } aria-describedby={ labelId }
/> />
) } ) }
@ -101,20 +100,12 @@ Tag.propTypes = {
* A function called when the remove X is clicked. If not used, no X icon will display. * A function called when the remove X is clicked. If not used, no X icon will display.
*/ */
remove: PropTypes.func, remove: PropTypes.func,
/**
* The label for removing this item (shown when hovering on X, or read to screen reader users). Defaults to "Remove tag".
*/
removeLabel: PropTypes.string,
/** /**
* A more descriptive label for screen reader users. Defaults to the `name` prop. * A more descriptive label for screen reader users. Defaults to the `name` prop.
*/ */
screenReaderLabel: PropTypes.string, screenReaderLabel: PropTypes.string,
}; };
Tag.defaultProps = {
removeLabel: __( 'Remove tag', 'wc-admin' ),
};
export default withState( { export default withState( {
isVisible: false, isVisible: false,
} )( withInstanceId( Tag ) ); } )( withInstanceId( Tag ) );