diff --git a/.changeset/search-button-current-space.md b/.changeset/search-button-current-space.md new file mode 100644 index 000000000..d627612c7 --- /dev/null +++ b/.changeset/search-button-current-space.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Let search buttons open search limited to the current space. diff --git a/packages/gitbook/src/components/DocumentView/InlineActionButton.tsx b/packages/gitbook/src/components/DocumentView/InlineActionButton.tsx index d794bef67..bf0a6ac04 100644 --- a/packages/gitbook/src/components/DocumentView/InlineActionButton.tsx +++ b/packages/gitbook/src/components/DocumentView/InlineActionButton.tsx @@ -13,9 +13,14 @@ const INPUT_SIZE_MAP: Record, 'small' | 'medium }; export function InlineActionButton( - props: { action: 'ask' | 'search'; query?: string } & { buttonProps: ButtonProps } // TODO: Type this properly: Pick & { buttonProps: ButtonProps } + props: { + action: 'ask' | 'search'; + query?: string; + /** Where a search runs: the whole site, or only the space the visitor is reading. */ + scope?: 'site' | 'space'; + } & { buttonProps: ButtonProps } // TODO: Type this properly: Pick & { buttonProps: ButtonProps } ) { - const { action, query, buttonProps } = props; + const { action, query, scope, buttonProps } = props; const { assistants } = useAI(); const chatState = useAIChatState(); @@ -29,7 +34,7 @@ export function InlineActionButton( setSearchState((prev) => ({ ...prev, ask: null, - scope: 'default', + scope: scope === 'space' ? 'current' : 'default', query: value ?? query, open: true, })); diff --git a/packages/gitbook/src/components/DocumentView/InlineButton.tsx b/packages/gitbook/src/components/DocumentView/InlineButton.tsx index 40ba19c41..7ea119549 100644 --- a/packages/gitbook/src/components/DocumentView/InlineButton.tsx +++ b/packages/gitbook/src/components/DocumentView/InlineButton.tsx @@ -47,6 +47,7 @@ export function InlineButton(props: InlineProps) { );