Ensure package names display correctly if only one item is in package (https://github.com/woocommerce/woocommerce-blocks/pull/6815)

* Check package length >= 1 to show package name

* Check shipping rates length in order shipping packages slot

* Fix TS error where boolean value could be undefined

* Show items if there is more than one shipping rate
This commit is contained in:
Thomas Roberts 2022-08-02 04:51:21 -07:00 committed by Albert Juhé Lluveras
parent fbb0e1e6ee
commit 5fe61143d8
2 changed files with 6 additions and 3 deletions

View File

@ -63,8 +63,8 @@ const Packages = ( {
key={ packageId }
packageId={ packageId }
packageData={ packageData }
collapsible={ collapsible }
collapse={ collapse }
collapsible={ !! collapsible }
collapse={ !! collapse }
showItems={
showItems || packageData?.shipping_rates?.length > 1
}
@ -167,6 +167,7 @@ const ShippingRatesControl = ( {
ShippingRatesControlPackage,
},
context,
shippingRates,
};
const { isEditor } = useEditorContext();
@ -192,6 +193,7 @@ const ShippingRatesControl = ( {
/>
<ExperimentalOrderShippingPackages>
<Packages
showItems={ shippingRates.length > 1 }
packages={ shippingRates }
noResultsMessage={ noResultsMessage }
renderOption={ renderOption }

View File

@ -23,9 +23,10 @@ const Slot = ( {
cart,
components,
context,
shippingRates,
} ) => {
const { fills } = useSlot( slotName );
const hasMultiplePackages = fills.length > 1;
const hasMultiplePackages = fills.length > 1 || shippingRates?.length > 1;
return (
<OrderShippingPackagesSlot
className={ classnames(