Skip to content

Commit 039bdda

Browse files
feat: update click event and styles
1 parent 3b25035 commit 039bdda

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

packages/template-retail-react-app/app/components/search/index.jsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,13 @@ const Search = (props) => {
224224
}
225225
}
226226

227-
const clearInput = () => {
227+
const clearInput = useCallback(() => {
228228
searchInputRef.current?.blur()
229229
setIsOpen(false)
230-
}
230+
}, [])
231231

232232
// Function to set pre-chat fields only when launching a new chat session
233-
const setPrechatFieldsForNewSession = () => {
233+
const setPrechatFieldsForNewSession = useCallback(() => {
234234
// Only set pre-chat fields if this is a new chat launch (not already launched)
235235
if (!miawChatRef.current.newChatLaunched) {
236236
if (window.embeddedservice_bootstrap?.prechatAPI) {
@@ -247,7 +247,17 @@ const Search = (props) => {
247247
})
248248
}
249249
}
250-
}
250+
}, [
251+
siteId,
252+
locale,
253+
commerceOrgId,
254+
usid,
255+
refreshToken,
256+
sfLanguage,
257+
appOrigin,
258+
buildUrl,
259+
location
260+
])
251261

252262
useEffect(() => {
253263
const handleEmbeddedMessageSent = (e) => {
@@ -274,7 +284,7 @@ const Search = (props) => {
274284
window.removeEventListener('onEmbeddedMessageSent', handleEmbeddedMessageSent)
275285
}
276286
}, [])
277-
const launchChat = () => {
287+
const launchChat = useCallback(() => {
278288
// Set pre-chat fields only for new sessions
279289
setPrechatFieldsForNewSession()
280290

@@ -295,7 +305,7 @@ const Search = (props) => {
295305
?.catch((err) => {
296306
console.error('launchChat error', err)
297307
})
298-
}
308+
}, [setPrechatFieldsForNewSession])
299309

300310
const onSubmitSearch = (e) => {
301311
e.preventDefault()

packages/template-retail-react-app/app/components/search/partials/ask-assistant-banner.jsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import React from 'react'
88
import PropTypes from 'prop-types'
99
import {Box, Text} from '@salesforce/retail-react-app/app/components/shared/ui'
10-
import {FormattedMessage, useIntl} from 'react-intl'
10+
import {useIntl} from 'react-intl'
1111
import {SparkleIcon, ChevronRightIcon} from '@salesforce/retail-react-app/app/components/icons'
1212

1313
const AskAssistantBanner = ({onClick, styles}) => {
@@ -24,7 +24,6 @@ const AskAssistantBanner = ({onClick, styles}) => {
2424

2525
const handleInteraction = (e) => {
2626
e.preventDefault()
27-
e.stopPropagation()
2827
onClick?.()
2928
}
3029

@@ -34,7 +33,6 @@ const AskAssistantBanner = ({onClick, styles}) => {
3433
as="button"
3534
type="button"
3635
textAlign="left"
37-
onMouseDown={handleInteraction}
3836
onClick={handleInteraction}
3937
aria-label={ariaLabel}
4038
>
@@ -43,22 +41,12 @@ const AskAssistantBanner = ({onClick, styles}) => {
4341
</Box>
4442
<Box {...styles.askAssistantBannerContent}>
4543
<Box {...styles.askAssistantBannerTitleRow}>
46-
<Text {...styles.askAssistantBannerTitle}>
47-
<FormattedMessage
48-
defaultMessage="Ask Shopping Agent"
49-
id="search.suggestions.askAssistant.title"
50-
/>
51-
</Text>
44+
<Text {...styles.askAssistantBannerTitle}>{title}</Text>
5245
<Box {...styles.askAssistantBannerArrow}>
5346
<ChevronRightIcon boxSize={5} color="gray.800" />
5447
</Box>
5548
</Box>
56-
<Text {...styles.askAssistantBannerDescription}>
57-
<FormattedMessage
58-
defaultMessage="Discover, compare, and shop smarter with your personal Shopping Agent."
59-
id="search.suggestions.askAssistant.description"
60-
/>
61-
</Text>
49+
<Text {...styles.askAssistantBannerDescription}>{description}</Text>
6250
</Box>
6351
</Box>
6452
)

packages/template-retail-react-app/app/components/search/partials/ask-assistant-banner.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ test('calls onClick when banner is clicked', async () => {
4545
})
4646
await user.click(button)
4747

48-
expect(onClick).toHaveBeenCalledTimes(2)
48+
expect(onClick).toHaveBeenCalledTimes(1)
4949
})

packages/template-retail-react-app/app/theme/components/project/search-suggestions.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ export default {
8080
},
8181
askAssistantBanner: {
8282
borderRadius: {base: 'md', md: 0},
83-
borderTopLeftRadius: {base: 'md', md: 0},
84-
borderTopRightRadius: {base: 'md', md: 0},
8583
padding: {base: '14px 24px', md: '14px 30%'},
8684
margin: 0,
8785
marginBottom: {base: 0, md: -6},

0 commit comments

Comments
 (0)