-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(atomic): fix atomic-commerce-search-box needlessly requesting sug…
…gestions when input is disabled (#4096) Calling `searchBox.updateText()` triggers a query suggestion request in Headless: This is fine, and generally what implementers requires the search box to do. However, in atomic, we've "split" the suggestion outside the searchbox component itself into a `SuggestionManager` utility class, which should be the one in charge of requesting suggestions when necessary. To fix, exported `loadQuerySetActions` from Headless commerce, and use this action directly to update the state of the search box, without requesting `/querySuggest`. https://coveord.atlassian.net/browse/KIT-3320 --------- Co-authored-by: Frederic Beaudoin <fbeaudoin@coveo.com>
- Loading branch information
1 parent
360b604
commit 49e9415
Showing
10 changed files
with
166 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/headless/src/features/commerce/query-set/query-set-actions-loader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {PayloadAction} from '@reduxjs/toolkit'; | ||
import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; | ||
import { | ||
RegisterQuerySetQueryActionCreatorPayload, | ||
UpdateQuerySetQueryActionCreatorPayload, | ||
} from '../../query-set/query-set-actions'; | ||
import {querySetReducer} from '../../query-set/query-set-slice'; | ||
import {registerQuerySetQuery, updateQuerySetQuery} from './query-set-actions'; | ||
|
||
export type { | ||
RegisterQuerySetQueryActionCreatorPayload, | ||
UpdateQuerySetQueryActionCreatorPayload, | ||
}; | ||
|
||
/** | ||
* The query set action creators. | ||
* | ||
* In Open Beta. Reach out to your Coveo team for support in adopting this. | ||
*/ | ||
export interface QuerySetActionCreators { | ||
/** | ||
* Registers a query set query. | ||
* | ||
* @param payload - The action creator payload. | ||
* @returns A dispatchable action. | ||
*/ | ||
registerQuerySetQuery( | ||
payload: RegisterQuerySetQueryActionCreatorPayload | ||
): PayloadAction<RegisterQuerySetQueryActionCreatorPayload>; | ||
|
||
/** | ||
* Updates a query set query. | ||
* | ||
* @param payload - The action creator payload. | ||
* @returns A dispatchable action. | ||
*/ | ||
updateQuerySetQuery( | ||
payload: UpdateQuerySetQueryActionCreatorPayload | ||
): PayloadAction<UpdateQuerySetQueryActionCreatorPayload>; | ||
} | ||
|
||
/** | ||
* Loads the query set reducer and returns the possible commerce query set action creators. | ||
* | ||
* In Open Beta. Reach out to your Coveo team for support in adopting this. | ||
* | ||
* @param engine - The commerce engine. | ||
* @returns An object holding the action creators. | ||
*/ | ||
export function loadQuerySetActions(engine: CommerceEngine) { | ||
engine.addReducers({querySetReducer}); | ||
return { | ||
registerQuerySetQuery, | ||
updateQuerySetQuery, | ||
}; | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/headless/src/features/commerce/query-set/query-set-actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {createAction} from '@reduxjs/toolkit'; | ||
import {validatePayload} from '../../../utils/validate-payload'; | ||
import { | ||
RegisterQuerySetQueryActionCreatorPayload, | ||
UpdateQuerySetQueryActionCreatorPayload, | ||
querySetDefinition, | ||
} from '../../query-set/query-set-actions'; | ||
|
||
export const registerQuerySetQuery = createAction( | ||
'commerce/querySet/register', | ||
(payload: RegisterQuerySetQueryActionCreatorPayload) => | ||
validatePayload(payload, querySetDefinition) | ||
); | ||
|
||
export const updateQuerySetQuery = createAction( | ||
'commerce/querySet/update', | ||
(payload: UpdateQuerySetQueryActionCreatorPayload) => | ||
validatePayload(payload, querySetDefinition) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters