mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
Fix embed search suggested questions not opening the assistant (#4514)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix suggested question clicks in the embed search not opening the assistant.
|
||||
@@ -163,16 +163,16 @@ export function useSearchLink(): (
|
||||
return {
|
||||
href: `?${searchParams.toString()}`,
|
||||
prefetch: false,
|
||||
onClick: (event) => {
|
||||
onClick: async (event) => {
|
||||
event.preventDefault();
|
||||
callback?.();
|
||||
setSearchState((prev) => ({
|
||||
await setSearchState((prev) => ({
|
||||
...prev,
|
||||
query: params.query !== undefined ? params.query : null,
|
||||
ask: params.ask !== undefined ? params.ask : null,
|
||||
scope: params.scope !== undefined ? params.scope : 'default',
|
||||
open: params.open !== undefined ? params.open : false,
|
||||
}));
|
||||
callback?.();
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -271,7 +271,7 @@ export function useSearchController(
|
||||
}, [abort, siteSpace.id]);
|
||||
|
||||
const askInAssistant = React.useCallback(
|
||||
(assistantIndex = 0) => {
|
||||
async (assistantIndex = 0) => {
|
||||
const assistant = assistants[assistantIndex];
|
||||
if (!assistant || !normalizedQuery) {
|
||||
return;
|
||||
@@ -282,13 +282,13 @@ export function useSearchController(
|
||||
}
|
||||
|
||||
abort();
|
||||
assistant.open(normalizedQuery);
|
||||
setSearchState({
|
||||
await setSearchState({
|
||||
ask: normalizedQuery,
|
||||
query: null,
|
||||
scope: state?.scope ?? 'default',
|
||||
open: assistant.mode === 'search',
|
||||
});
|
||||
assistant.open(normalizedQuery);
|
||||
},
|
||||
[abort, assistants, normalizedQuery, setSearchState, siteSpace.id, state?.scope]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user