Skip to content

Commit 89c0cc0

Browse files
fix: salesforce commerce cloud when there is a untitled product listing from salesforce (#10070)
1 parent c2f8b4a commit 89c0cc0

7 files changed

Lines changed: 37 additions & 38 deletions

File tree

apps/salesforce-commerce-cloud/src/components/dialog/CategoryPreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const CategoryPreview = (props: { category: any }) => {
1313
<Text as="span" fontWeight="fontWeightDemiBold">
1414
{category.name?.default}
1515
</Text>{' '}
16-
(Catalog: {catalogInfo?.name?.default ? catalogInfo.name.default : category.catalogId})
16+
(Catalog: {catalogInfo?.name?.default || category.catalogId})
1717
</Text>
1818
{category.pageDescription?.default && (
1919
<Text as="div">{category.pageDescription.default}</Text>

apps/salesforce-commerce-cloud/src/components/dialog/CategorySearchResults.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ const CategorySearchResults = (props: SearchResultsProps) => {
1717
const resultsWrapperStyle = css`
1818
max-height: ${height}px;
1919
padding: ${tokens.spacingL};
20-
padding-bottom: 0;
21-
@media screen and (min-height: ${stickyHeaderBreakpoint}px;) {
22-
padding-top: ${tokens.spacingL + headerHeight}px;
23-
}
20+
overflow-y: auto;
2421
`;
2522

2623
return (
@@ -58,7 +55,7 @@ const CategorySearchResult = (props: SearchResultProps) => {
5855
<TagsIcon />
5956
<Flex flexDirection="column" marginLeft="spacingS">
6057
<Text as="div" fontWeight="fontWeightDemiBold" fontSize="fontSizeM">
61-
{result.name.default}
58+
{result.name?.default || 'Untitled Category'}
6259
</Text>
6360
<Text as="div" fontWeight="fontWeightMedium" fontSize="fontSizeS" fontColor="gray600">
6461
ID: {result.id}
@@ -70,7 +67,7 @@ const CategorySearchResult = (props: SearchResultProps) => {
7067
|
7168
</Box>
7269
<Box as="span" css={categoryStyle}>
73-
Catalog: {result.name?.default ? result.name.default : result.catalogId}
70+
Catalog: {result.name?.default || result.catalogId}
7471
</Box>
7572
</Text>
7673
</Flex>

apps/salesforce-commerce-cloud/src/components/dialog/ProductPreview.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ProductPreview = (props: { product: any }) => {
77
const { product } = props;
88

99
let description = 'Description';
10-
if (product.shortDescription.default) {
10+
if (product.shortDescription?.default) {
1111
description =
1212
product.shortDescription.default.markup.length > descriptionLength
1313
? `${product.shortDescription.default.markup.substring(0, descriptionLength)}...`
@@ -18,10 +18,17 @@ const ProductPreview = (props: { product: any }) => {
1818

1919
return (
2020
<>
21-
{imageUrl && <img src={imageUrl} alt={product.image.alt.default} height="75" width="75" />}
21+
{imageUrl && (
22+
<img
23+
src={imageUrl}
24+
alt={product.image?.alt?.default || 'Product image'}
25+
height="75"
26+
width="75"
27+
/>
28+
)}
2229
<Flex flexDirection="column" marginLeft="spacingS">
2330
<Text as="div" fontWeight="fontWeightDemiBold">
24-
{product.name.default} (ID: {product.id})
31+
{product.name?.default || 'Untitled Product'} (ID: {product.id})
2532
</Text>
2633
<Text as="div">{description}</Text>
2734
</Flex>

apps/salesforce-commerce-cloud/src/components/dialog/ProductSearchResults.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ import {
1616
const ProductSearchResults = (props: SearchResultsProps) => {
1717
const resultsStyles = css`
1818
max-height: ${height}px;
19-
padding: ${tokens.spacingL} ${tokens.spacingL} 0 ${tokens.spacingL};
20-
@media screen and (min-height: ${stickyHeaderBreakpoint}px;) {
21-
padding: calc(${tokens.spacingL + headerHeight}px) ${tokens.spacingL} 0 ${tokens.spacingL};
22-
}
19+
padding: ${tokens.spacingL};
20+
overflow-y: auto;
2321
`;
2422

2523
return (
@@ -147,12 +145,12 @@ const ProductSearchResult = (props: SearchResultProps) => {
147145
onError={() => setImageHasErrored(true)}
148146
style={{ display: imageHasLoaded ? 'block' : 'none' }}
149147
src={result.image?.absUrl}
150-
alt={result.image?.alt.default}
148+
alt={result.image?.alt?.default || 'Product image'}
151149
data-test-id="image"
152150
/>
153151
</div>
154152
)}
155-
<p css={resultNameStyles}>{result.name.default}</p>
153+
<p css={resultNameStyles}>{result.name?.default || 'Untitled Product'}</p>
156154
<p css={resultIdStyles}>ID: {result.id}</p>
157155
{fieldType === 'category' && <p css={resultIdStyles}>Catalog ID: {result.catalogId}</p>}
158156
</div>

apps/salesforce-commerce-cloud/src/components/dialog/SearchBar.tsx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,17 @@ const SearchBar = (props: SearchBarProps) => {
4242

4343
const headerStyles = css`
4444
border-bottom: 1px solid ${tokens.gray300};
45-
padding-bottom: ${tokens.spacingL};
46-
@media screen and (min-height: ${props.stickyHeaderBreakpoint}px) {
47-
background-color: white;
48-
position: fixed;
49-
top: 0;
50-
z-index: 1;
51-
width: calc(100% - 2rem);
52-
}
45+
padding: ${tokens.spacingM} ${tokens.spacingL} ${tokens.spacingL} ${tokens.spacingL};
46+
background-color: white;
47+
position: sticky;
48+
top: 0;
49+
z-index: 1;
5350
`;
5451

5552
const controlProps = { ...props, fieldType };
5653

5754
return (
58-
<Flex as="header" justifyContent="space-between" alignItems="flex-start" css={headerStyles}>
55+
<Flex as="header" justifyContent="space-between" alignItems="center" css={headerStyles}>
5956
<LeftSideControls {...controlProps} />
6057
<RightSideControls {...controlProps} />
6158
</Flex>
@@ -112,7 +109,7 @@ const LeftSideControls = (props: SearchControlProps) => {
112109

113110
const RightSideControls = (props: SearchControlProps) => {
114111
return (
115-
<Flex justifyContent="flex-end" flexGrow={1}>
112+
<Flex justifyContent="flex-end" alignItems="center" flexGrow={1} gap="spacingM">
116113
<SelectionList
117114
items={props.selectedItems}
118115
itemsInfo={props.selectedData}
@@ -148,12 +145,7 @@ const SelectionList = (props: SelectionListProps) => {
148145
};
149146

150147
return (
151-
<Grid
152-
columns={9}
153-
justifyContent="space-between"
154-
columnGap="spacingXs"
155-
rowGap="spacingXs"
156-
marginRight="spacingXs">
148+
<Flex gap="spacingXs" flexWrap="wrap" alignItems="center">
157149
{items &&
158150
items.map((itemId: string) => (
159151
<SelectionListItem
@@ -164,7 +156,7 @@ const SelectionList = (props: SelectionListProps) => {
164156
fieldType={props.fieldType}
165157
/>
166158
))}
167-
</Grid>
159+
</Flex>
168160
);
169161
};
170162

apps/salesforce-commerce-cloud/src/components/field/ItemCard.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,16 @@ const ItemPreview = (props: ItemPreviewProps) => {
8989
return (
9090
<>
9191
{useImage && imageUrl && (
92-
<img src={imageUrl} alt={itemData.image.alt.default} height="75" width="75" />
92+
<img
93+
src={imageUrl}
94+
alt={itemData.image?.alt?.default || 'Product image'}
95+
height="75"
96+
width="75"
97+
/>
9398
)}
9499
<Flex flexDirection="column" marginLeft="spacingS">
95100
<Text as="div" fontWeight="fontWeightDemiBold" fontSize="fontSizeM">
96-
{itemData.name.default}
101+
{itemData.name?.default || 'Untitled Item'}
97102
</Text>
98103
<Text as="div" fontWeight="fontWeightMedium" fontSize="fontSizeS" fontColor="gray600">
99104
ID: {itemData.id}
@@ -107,7 +112,7 @@ const ItemPreview = (props: ItemPreviewProps) => {
107112
|
108113
</Box>
109114
<Box as="span" css={categoryStyle}>
110-
Catalog: {itemData.name?.default ? itemData.name.default : itemData.catalogId}
115+
Catalog: {itemData.name?.default || itemData.catalogId}
111116
</Box>
112117
</>
113118
)}

apps/salesforce-commerce-cloud/src/locations/Dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ const Dialog = () => {
3232
};
3333

3434
return (
35-
<Flex flexDirection="column">
35+
<>
3636
<Modal.Header title={makeTitle(selectMultiple, fieldType)} onClose={() => sdk.close()} />
3737
<SearchPicker />
38-
</Flex>
38+
</>
3939
);
4040
};
4141

0 commit comments

Comments
 (0)