diff --git a/frontend/src/metabase/palette/components/PaletteResults.unit.spec.tsx b/frontend/src/metabase/palette/components/PaletteResults.unit.spec.tsx index d96258ea0b3693b5e86fa74b48b276b213bb023d..da3c6d7f7e28f366560627a312f136bbb0ad369f 100644 --- a/frontend/src/metabase/palette/components/PaletteResults.unit.spec.tsx +++ b/frontend/src/metabase/palette/components/PaletteResults.unit.spec.tsx @@ -261,4 +261,14 @@ describe("PaletteResults", () => { // One call is always made to determine if the instance has models inside useCommandPaletteBasicActions expect(fetchMock.calls("path:/api/search").length).toBe(1); }); + + it("should provide a link to docs with the proper url param", async () => { + setup({ query: "model" }); + expect( + await screen.findByRole("link", { name: /Search documentation/ }), + ).toHaveAttribute("href", expect.stringContaining("?query=model")); + + // One call is always made to determine if the instance has models inside useCommandPaletteBasicActions + expect(fetchMock.calls("path:/api/search").length).toBe(2); + }); }); diff --git a/frontend/src/metabase/palette/hooks/useCommandPalette.tsx b/frontend/src/metabase/palette/hooks/useCommandPalette.tsx index 299f8dcbace7bd006b805f3cfeb0b45ca69c2575..67a24b19d382101bf64009af1baeeb839b3778e6 100644 --- a/frontend/src/metabase/palette/hooks/useCommandPalette.tsx +++ b/frontend/src/metabase/palette/hooks/useCommandPalette.tsx @@ -85,6 +85,9 @@ export const useCommandPalette = ({ ); const docsAction = useMemo<PaletteAction[]>(() => { + const link = debouncedSearchText + ? getDocsSearchUrl({ query: debouncedSearchText }) + : docsUrl; const ret: PaletteAction[] = [ { id: "search_docs", @@ -95,11 +98,10 @@ export const useCommandPalette = ({ keywords: debouncedSearchText, // Always match the debouncedSearchText string icon: "document", perform: () => { - if (debouncedSearchText) { - window.open(getDocsSearchUrl({ debouncedSearchText })); - } else { - window.open(docsUrl); - } + window.open(link); + }, + extra: { + href: link, }, }, ];