diff --git a/plugins/woocommerce-blocks/assets/js/atomic/components/product/button/index.js b/plugins/woocommerce-blocks/assets/js/atomic/components/product/button/index.js index 14936ef01ab..a56054c833c 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/components/product/button/index.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/components/product/button/index.js @@ -32,7 +32,7 @@ import { COLLECTIONS_STORE_KEY as storeKey } from '@woocommerce/block-data'; * @type {bool} addingToCart Whether the product is currently being * added to the cart (true). * @type {bool} cartIsLoading Whether the cart is being loaded. - * @type {function} addToCart An action dispatcher for adding a single + * @type {Function} addToCart An action dispatcher for adding a single * quantity of the product to the cart. * Receives no arguments, it operates on the * current product. diff --git a/plugins/woocommerce-blocks/assets/js/base/components/checkbox-list/index.js b/plugins/woocommerce-blocks/assets/js/base/components/checkbox-list/index.js index 24bf585bcbc..eaf5b4267fb 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/checkbox-list/index.js +++ b/plugins/woocommerce-blocks/assets/js/base/components/checkbox-list/index.js @@ -3,13 +3,7 @@ */ import { __, sprintf } from '@wordpress/i18n'; import PropTypes from 'prop-types'; -import { - Fragment, - useCallback, - useMemo, - useState, - useEffect, -} from '@wordpress/element'; +import { Fragment, useMemo, useState } from '@wordpress/element'; import classNames from 'classnames'; /** @@ -24,17 +18,13 @@ const CheckboxList = ( { className, onChange = () => {}, options = [], + checked = [], isLoading = false, + isDisabled = false, limit = 10, } ) => { - // Holds all checked options. - const [ checked, setChecked ] = useState( [] ); const [ showExpanded, setShowExpanded ] = useState( false ); - useEffect( () => { - onChange( checked ); - }, [ checked ] ); - const placeholder = useMemo( () => { return [ ...Array( 5 ) ].map( ( x, i ) => (
  • { - const isChecked = event.target.checked; - const checkedValue = event.target.value; - const newChecked = checked.filter( - ( value ) => value !== checkedValue - ); - - if ( isChecked ) { - newChecked.push( checkedValue ); - newChecked.sort(); - } - - setChecked( newChecked ); - }, - [ checked ] - ); - const renderedShowMore = useMemo( () => { const optionCount = options.length; return ( @@ -135,8 +107,9 @@ const CheckboxList = ( { type="checkbox" id={ option.key } value={ option.key } - onChange={ onCheckboxChange } + onChange={ onChange } checked={ checked.includes( option.key ) } + disabled={ isDisabled } />