This repository was archived by the owner on Feb 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
assets/js/base/components/cart-checkout/shipping-rates-control-package Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313 useStoreEvents ,
1414} from '@woocommerce/base-context/hooks' ;
1515import { sanitizeHTML } from '@woocommerce/utils' ;
16+ import { debounce } from 'lodash' ;
1617
1718/**
1819 * Internal dependencies
@@ -90,14 +91,17 @@ export const ShippingRatesControlPackage = ( {
9091 ) }
9192 </ >
9293 ) ;
93- const onSelectRate = useCallback (
94- ( newShippingRateId : string ) => {
95- selectShippingRate ( newShippingRateId , packageId ) ;
96- dispatchCheckoutEvent ( 'set-selected-shipping-rate' , {
97- shippingRateId : newShippingRateId ,
98- } ) ;
99- } ,
100- [ dispatchCheckoutEvent , packageId , selectShippingRate ]
94+ const onSelectRate = debounce (
95+ useCallback (
96+ ( newShippingRateId : string ) => {
97+ selectShippingRate ( newShippingRateId , packageId ) ;
98+ dispatchCheckoutEvent ( 'set-selected-shipping-rate' , {
99+ shippingRateId : newShippingRateId ,
100+ } ) ;
101+ } ,
102+ [ dispatchCheckoutEvent , packageId , selectShippingRate ]
103+ ) ,
104+ 1000
101105 ) ;
102106 const packageRatesProps = {
103107 className,
You can’t perform that action at this time.
0 commit comments