Skip to content

Commit 91a2538

Browse files
fix(atomic-react): render empty link container when display is other than grid (#4604)
https://coveord.atlassian.net/browse/KIT-3561 At the moment, we're rendering the default link container (i.e., an AtomicProductLink) even on list and table display, making the entire result clickable. This should only be the case in grid display. **Before fix**: <video src=https://github.com/user-attachments/assets/24d6321c-f8d7-48de-9a35-b8da3b8f9345 /> **After fix**: <video src=https://github.com/user-attachments/assets/b35e26b3-3586-4c20-9e04-5310345fd48b />
1 parent 44563fd commit 91a2538

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

packages/atomic-react/src/components/commerce/CommerceProductListWrapper.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ export const ListWrapper: React.FC<WrapperProps> = (props) => {
4444
return renderToString(templateResult.contentTemplate);
4545
} else {
4646
createRoot(root).render(templateResult);
47-
createRoot(linkContainer!).render(
48-
<AtomicProductLink></AtomicProductLink>
49-
);
47+
otherProps.display === 'grid'
48+
? createRoot(linkContainer!).render(
49+
<AtomicProductLink></AtomicProductLink>
50+
)
51+
: createRoot(linkContainer!).render(<></>);
5052
return renderToString(templateResult);
5153
}
5254
}

packages/atomic-react/src/components/commerce/CommerceRecommendationListWrapper.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ export const ListWrapper: React.FC<WrapperProps> = (props) => {
4444
return renderToString(templateResult.contentTemplate);
4545
} else {
4646
createRoot(root).render(templateResult);
47-
createRoot(linkContainer!).render(
48-
<AtomicProductLink></AtomicProductLink>
49-
);
47+
otherProps.display === 'grid'
48+
? createRoot(linkContainer!).render(
49+
<AtomicProductLink></AtomicProductLink>
50+
)
51+
: createRoot(linkContainer!).render(<></>);
5052
return renderToString(templateResult);
5153
}
5254
}

packages/atomic-react/src/components/recommendation/RecsListWrapper.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ export const RecsListWrapper: React.FC<WrapperProps> = (props) => {
4242
return renderToString(templateResult.contentTemplate);
4343
} else {
4444
createRoot(root).render(templateResult);
45-
createRoot(linkContainer!).render(
46-
<AtomicResultLink></AtomicResultLink>
47-
);
45+
otherProps.display === 'grid'
46+
? createRoot(linkContainer!).render(
47+
<AtomicResultLink></AtomicResultLink>
48+
)
49+
: createRoot(linkContainer!).render(<></>);
4850
return renderToString(templateResult);
4951
}
5052
});

packages/atomic-react/src/components/search/ResultListWrapper.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ export const ResultListWrapper: React.FC<WrapperProps> = (props) => {
4242
return renderToString(templateResult.contentTemplate);
4343
} else {
4444
createRoot(root).render(templateResult);
45-
createRoot(linkContainer!).render(
46-
<AtomicResultLink></AtomicResultLink>
47-
);
45+
otherProps.display === 'grid'
46+
? createRoot(linkContainer!).render(
47+
<AtomicResultLink></AtomicResultLink>
48+
)
49+
: createRoot(linkContainer!).render(<></>);
4850
return renderToString(templateResult);
4951
}
5052
});

0 commit comments

Comments
 (0)