Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 7515da9

Browse files
authored
Merge branch 'trunk' into release/9.7.0
2 parents c1b855c + e66a26f commit 7515da9

File tree

1 file changed

+12
-8
lines changed
  • assets/js/base/components/cart-checkout/shipping-rates-control-package

1 file changed

+12
-8
lines changed

assets/js/base/components/cart-checkout/shipping-rates-control-package/index.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
useStoreEvents,
1414
} from '@woocommerce/base-context/hooks';
1515
import { 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,

0 commit comments

Comments
 (0)