Skip to content
Snippets Groups Projects
Unverified Commit a8d5ea64 authored by Nick Fitzpatrick's avatar Nick Fitzpatrick Committed by GitHub
Browse files

fix(command-palette): fix docs url (#44113)

parent a95ff7f5
No related branches found
No related tags found
No related merge requests found
......@@ -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);
});
});
......@@ -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,
},
},
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment