diff --git a/app/actions/definitions/documents.tsx b/app/actions/definitions/documents.tsx
index 9bd3565bc..7896f7dcf 100644
--- a/app/actions/definitions/documents.tsx
+++ b/app/actions/definitions/documents.tsx
@@ -10,6 +10,7 @@ import {
ShapesIcon,
ImportIcon,
PinIcon,
+ SearchIcon,
} from "outline-icons";
import * as React from "react";
import getDataTransferFiles from "@shared/utils/getDataTransferFiles";
@@ -17,7 +18,7 @@ import DocumentTemplatize from "~/scenes/DocumentTemplatize";
import { createAction } from "~/actions";
import { DocumentSection } from "~/actions/sections";
import history from "~/utils/history";
-import { homePath, newDocumentPath } from "~/utils/routeHelpers";
+import { homePath, newDocumentPath, searchPath } from "~/utils/routeHelpers";
export const openDocument = createAction({
name: ({ t }) => t("Open document"),
@@ -318,6 +319,17 @@ export const createTemplate = createAction({
},
});
+export const searchDocumentsForQuery = (searchQuery: string) =>
+ createAction({
+ id: "search",
+ section: DocumentSection,
+ name: ({ t }) =>
+ t(`Search documents for "{{searchQuery}}"`, { searchQuery }),
+ icon: ,
+ perform: () => history.push(searchPath(searchQuery)),
+ visible: ({ location }) => location.pathname !== searchPath(),
+ });
+
export const rootDocumentActions = [
openDocument,
createDocument,
diff --git a/app/actions/definitions/navigation.tsx b/app/actions/definitions/navigation.tsx
index 41f71c0f2..b64ff63d9 100644
--- a/app/actions/definitions/navigation.tsx
+++ b/app/actions/definitions/navigation.tsx
@@ -23,11 +23,7 @@ import stores from "~/stores";
import SearchQuery from "~/models/SearchQuery";
import KeyboardShortcuts from "~/scenes/KeyboardShortcuts";
import { createAction } from "~/actions";
-import {
- NavigationSection,
- SearchSection,
- RecentSearchesSection,
-} from "~/actions/sections";
+import { NavigationSection, RecentSearchesSection } from "~/actions/sections";
import history from "~/utils/history";
import {
organizationSettingsPath,
@@ -57,17 +53,6 @@ export const navigateToRecentSearchQuery = (searchQuery: SearchQuery) =>
perform: () => history.push(searchPath(searchQuery.query)),
});
-export const navigateToSearchQuery = (searchQuery: string) =>
- createAction({
- id: "search",
- section: SearchSection,
- name: ({ t }) =>
- t(`Search documents for "{{searchQuery}}"`, { searchQuery }),
- icon: ,
- perform: () => history.push(searchPath(searchQuery)),
- visible: ({ location }) => location.pathname !== searchPath(),
- });
-
export const navigateToDrafts = createAction({
name: ({ t }) => t("Drafts"),
section: NavigationSection,
diff --git a/app/actions/sections.ts b/app/actions/sections.ts
index 39549c6f1..2963e980f 100644
--- a/app/actions/sections.ts
+++ b/app/actions/sections.ts
@@ -14,5 +14,3 @@ export const UserSection = ({ t }: ActionContext) => t("People");
export const RecentSearchesSection = ({ t }: ActionContext) =>
t("Recent searches");
-
-export const SearchSection = "";
diff --git a/app/components/CommandBar.tsx b/app/components/CommandBar.tsx
index 809f1ecbd..3f63e4caa 100644
--- a/app/components/CommandBar.tsx
+++ b/app/components/CommandBar.tsx
@@ -48,9 +48,7 @@ function CommandBar() {
t("Type a command or search")
}…`}
/>
-
+
{ui.commandBarOpenedFromSidebar && (
diff --git a/app/components/CommandBarResults.tsx b/app/components/CommandBarResults.tsx
index 250269b67..7c2b59ee1 100644
--- a/app/components/CommandBarResults.tsx
+++ b/app/components/CommandBarResults.tsx
@@ -1,27 +1,14 @@
import { useMatches, KBarResults } from "kbar";
-import { orderBy } from "lodash";
import * as React from "react";
import styled from "styled-components";
import CommandBarItem from "~/components/CommandBarItem";
-import { SearchSection } from "~/actions/sections";
-type Props = {
- prioritizeSearchResults: boolean;
-};
-
-export default function CommandBarResults(props: Props) {
+export default function CommandBarResults() {
const { results, rootActionId } = useMatches();
return (
- // this is an unfortunate hack until kbar supports priority internally
- typeof item !== "string" &&
- item.section === SearchSection &&
- props.prioritizeSearchResults
- ? -1
- : 1
- )}
+ items={results}
maxHeight={400}
onRender={({ item, active }) =>
typeof item === "string" ? (
diff --git a/app/components/SearchActions.ts b/app/components/SearchActions.ts
index b18620bce..3dd6bf842 100644
--- a/app/components/SearchActions.ts
+++ b/app/components/SearchActions.ts
@@ -1,9 +1,8 @@
import { useKBar } from "kbar";
import * as React from "react";
-import {
- navigateToRecentSearchQuery,
- navigateToSearchQuery,
-} from "~/actions/definitions/navigation";
+import { searchDocumentsForQuery } from "~/actions/definitions/documents";
+import { navigateToRecentSearchQuery } from "~/actions/definitions/navigation";
+
import useCommandBarActions from "~/hooks/useCommandBarActions";
import useStores from "~/hooks/useStores";
@@ -18,7 +17,9 @@ export default function SearchActions() {
searchQuery: state.searchQuery,
}));
- useCommandBarActions(searchQuery ? [navigateToSearchQuery(searchQuery)] : []);
+ useCommandBarActions(
+ searchQuery ? [searchDocumentsForQuery(searchQuery)] : []
+ );
useCommandBarActions(searches.recent.map(navigateToRecentSearchQuery));