Fix product task text shown before accordion is expanded on stack layout
This commit is contained in:
parent
a287963fa4
commit
5453737747
|
@ -22,7 +22,7 @@
|
||||||
color: #007cba;
|
color: #007cba;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
margin-top: 25px;
|
margin-top: 21px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
|
|
|
@ -116,6 +116,7 @@ export const Products = () => {
|
||||||
<Stack
|
<Stack
|
||||||
items={ visibleProductTypes }
|
items={ visibleProductTypes }
|
||||||
onClickLoadSampleProduct={ loadSampleProduct }
|
onClickLoadSampleProduct={ loadSampleProduct }
|
||||||
|
showOtherOptions={ isExpanded }
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<CardLayout items={ visibleProductTypes } />
|
<CardLayout items={ visibleProductTypes } />
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
.woocommerce-stack__other-options {
|
.woocommerce-stack__other-options {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
|
margin-bottom: 4px;
|
||||||
color: $gray-700;
|
color: $gray-700;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,18 @@ type StackProps = {
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
} )[];
|
} )[];
|
||||||
onClickLoadSampleProduct: () => void;
|
onClickLoadSampleProduct: () => void;
|
||||||
|
showOtherOptions?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Stack: React.FC< StackProps > = ( {
|
const Stack: React.FC< StackProps > = ( {
|
||||||
items,
|
items,
|
||||||
onClickLoadSampleProduct,
|
onClickLoadSampleProduct,
|
||||||
|
showOtherOptions = true,
|
||||||
} ) => {
|
} ) => {
|
||||||
return (
|
return (
|
||||||
<div className="woocommerce-products-stack">
|
<div className="woocommerce-products-stack">
|
||||||
<List items={ items } />
|
<List items={ items } />
|
||||||
|
{ showOtherOptions && (
|
||||||
<Text className="woocommerce-stack__other-options">
|
<Text className="woocommerce-stack__other-options">
|
||||||
{ interpolateComponents( {
|
{ interpolateComponents( {
|
||||||
mixedString: __(
|
mixedString: __(
|
||||||
|
@ -49,7 +52,6 @@ const Stack: React.FC< StackProps > = ( {
|
||||||
</Link>
|
</Link>
|
||||||
),
|
),
|
||||||
LspLink: (
|
LspLink: (
|
||||||
// TODO: Update this to the load sample product.
|
|
||||||
<Link
|
<Link
|
||||||
href=""
|
href=""
|
||||||
type="wc-admin"
|
type="wc-admin"
|
||||||
|
@ -64,6 +66,7 @@ const Stack: React.FC< StackProps > = ( {
|
||||||
},
|
},
|
||||||
} ) }
|
} ) }
|
||||||
</Text>
|
</Text>
|
||||||
|
) }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -93,6 +93,10 @@ describe( 'Products', () => {
|
||||||
const fetchMock = jest.spyOn( global, 'fetch' );
|
const fetchMock = jest.spyOn( global, 'fetch' );
|
||||||
const { queryByText, getByRole } = render( <Products /> );
|
const { queryByText, getByRole } = render( <Products /> );
|
||||||
|
|
||||||
|
userEvent.click(
|
||||||
|
getByRole( 'button', { name: 'View more product types' } )
|
||||||
|
);
|
||||||
|
|
||||||
expect( queryByText( 'Load Sample Products' ) ).toBeInTheDocument();
|
expect( queryByText( 'Load Sample Products' ) ).toBeInTheDocument();
|
||||||
|
|
||||||
userEvent.click(
|
userEvent.click(
|
||||||
|
|
|
@ -27,6 +27,24 @@ describe( 'Stack', () => {
|
||||||
expect( queryAllByRole( 'link' ) ).toHaveLength( 2 );
|
expect( queryAllByRole( 'link' ) ).toHaveLength( 2 );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
it( 'should not render other product options', () => {
|
||||||
|
const { queryByText } = render(
|
||||||
|
<Stack
|
||||||
|
showOtherOptions={ false }
|
||||||
|
onClickLoadSampleProduct={ () => {} }
|
||||||
|
items={ [
|
||||||
|
{
|
||||||
|
...productTypes[ 0 ],
|
||||||
|
onClick: () => {},
|
||||||
|
},
|
||||||
|
] }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect( queryByText( 'Start Blank' ) ).not.toBeInTheDocument();
|
||||||
|
expect( queryByText( 'Load Sample Products' ) ).not.toBeInTheDocument();
|
||||||
|
} );
|
||||||
|
|
||||||
it( 'should call onClickLoadSampleProduct when the "Load Sample Products" link is clicked', async () => {
|
it( 'should call onClickLoadSampleProduct when the "Load Sample Products" link is clicked', async () => {
|
||||||
const onClickLoadSampleProduct = jest.fn();
|
const onClickLoadSampleProduct = jest.fn();
|
||||||
const { getByRole } = render(
|
const { getByRole } = render(
|
||||||
|
|
Loading…
Reference in New Issue