mirror of
https://github.com/vercel/commerce.git
synced 2025-03-31 17:25:53 +00:00
Disables link scroll on variant selection (#1109)
* Disables link scroll on variant selection * Fix TS error
This commit is contained in:
parent
326f516138
commit
29aaa8cac6
@ -38,7 +38,7 @@ export async function ThreeItemGrid() {
|
|||||||
const [firstProduct, secondProduct, thirdProduct] = homepageItems;
|
const [firstProduct, secondProduct, thirdProduct] = homepageItems;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="mx-auto max-w-screen-2xl gap-4 pb-4 lg:grid lg:grid-cols-6 lg:grid-rows-2">
|
<section className="mx-auto grid max-w-screen-2xl gap-4 pb-4 lg:grid-cols-6 lg:grid-rows-2">
|
||||||
<ThreeItemGridItem size="full" item={firstProduct} />
|
<ThreeItemGridItem size="full" item={firstProduct} />
|
||||||
<ThreeItemGridItem size="half" item={secondProduct} />
|
<ThreeItemGridItem size="half" item={secondProduct} />
|
||||||
<ThreeItemGridItem size="half" item={thirdProduct} />
|
<ThreeItemGridItem size="half" item={thirdProduct} />
|
||||||
|
@ -107,10 +107,14 @@ export function VariantSelector({
|
|||||||
)?.availableForSale;
|
)?.availableForSale;
|
||||||
|
|
||||||
const DynamicTag = isAvailableForSale ? Link : 'p';
|
const DynamicTag = isAvailableForSale ? Link : 'p';
|
||||||
|
const dynamicProps = {
|
||||||
|
...(isAvailableForSale && { scroll: false })
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DynamicTag
|
<DynamicTag
|
||||||
key={value}
|
key={value}
|
||||||
|
aria-disabled={!isAvailableForSale}
|
||||||
href={optionUrl}
|
href={optionUrl}
|
||||||
title={`${option.name} ${value}${!isAvailableForSale ? ' (Out of Stock)' : ''}`}
|
title={`${option.name} ${value}${!isAvailableForSale ? ' (Out of Stock)' : ''}`}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@ -123,6 +127,7 @@ export function VariantSelector({
|
|||||||
!isAvailableForSale
|
!isAvailableForSale
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
|
{...dynamicProps}
|
||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
</DynamicTag>
|
</DynamicTag>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user