Added debounce to shipping rate selection on cart (https://github.com/woocommerce/woocommerce-blocks/pull/8498)
This commit is contained in:
parent
a7f471d9ff
commit
6483ee08d0
|
@ -13,6 +13,7 @@ import {
|
|||
useStoreEvents,
|
||||
} from '@woocommerce/base-context/hooks';
|
||||
import { sanitizeHTML } from '@woocommerce/utils';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -90,14 +91,17 @@ export const ShippingRatesControlPackage = ( {
|
|||
) }
|
||||
</>
|
||||
);
|
||||
const onSelectRate = useCallback(
|
||||
( newShippingRateId: string ) => {
|
||||
selectShippingRate( newShippingRateId, packageId );
|
||||
dispatchCheckoutEvent( 'set-selected-shipping-rate', {
|
||||
shippingRateId: newShippingRateId,
|
||||
} );
|
||||
},
|
||||
[ dispatchCheckoutEvent, packageId, selectShippingRate ]
|
||||
const onSelectRate = debounce(
|
||||
useCallback(
|
||||
( newShippingRateId: string ) => {
|
||||
selectShippingRate( newShippingRateId, packageId );
|
||||
dispatchCheckoutEvent( 'set-selected-shipping-rate', {
|
||||
shippingRateId: newShippingRateId,
|
||||
} );
|
||||
},
|
||||
[ dispatchCheckoutEvent, packageId, selectShippingRate ]
|
||||
),
|
||||
1000
|
||||
);
|
||||
const packageRatesProps = {
|
||||
className,
|
||||
|
|
Loading…
Reference in New Issue