Revert command bar launch from Search sidebar
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
import { useKBar } from "kbar";
|
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { EditIcon, SearchIcon, ShapesIcon, HomeIcon } from "outline-icons";
|
import { EditIcon, SearchIcon, ShapesIcon, HomeIcon } from "outline-icons";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { DndProvider } from "react-dnd";
|
import { DndProvider } from "react-dnd";
|
||||||
import { HTML5Backend } from "react-dnd-html5-backend";
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useHistory, useLocation } from "react-router-dom";
|
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import Flex from "~/components/Flex";
|
import Flex from "~/components/Flex";
|
||||||
import Scrollable from "~/components/Scrollable";
|
import Scrollable from "~/components/Scrollable";
|
||||||
@@ -37,12 +35,9 @@ import TrashLink from "./components/TrashLink";
|
|||||||
|
|
||||||
function AppSidebar() {
|
function AppSidebar() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { ui, documents } = useStores();
|
const { documents } = useStores();
|
||||||
const team = useCurrentTeam();
|
const team = useCurrentTeam();
|
||||||
const user = useCurrentUser();
|
const user = useCurrentUser();
|
||||||
const { query } = useKBar();
|
|
||||||
const location = useLocation();
|
|
||||||
const history = useHistory();
|
|
||||||
const can = usePolicy(team.id);
|
const can = usePolicy(team.id);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -59,16 +54,6 @@ function AppSidebar() {
|
|||||||
[dndArea]
|
[dndArea]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSearch = React.useCallback(() => {
|
|
||||||
const isSearching = location.pathname.startsWith(searchPath());
|
|
||||||
if (isSearching) {
|
|
||||||
history.push(searchPath());
|
|
||||||
} else {
|
|
||||||
ui.commandBarOpened();
|
|
||||||
query.toggle();
|
|
||||||
}
|
|
||||||
}, [ui, location, history, query]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sidebar ref={handleSidebarRef}>
|
<Sidebar ref={handleSidebarRef}>
|
||||||
{dndArea && (
|
{dndArea && (
|
||||||
@@ -94,7 +79,7 @@ function AppSidebar() {
|
|||||||
label={t("Home")}
|
label={t("Home")}
|
||||||
/>
|
/>
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
onClick={handleSearch}
|
to={searchPath()}
|
||||||
icon={<SearchIcon color="currentColor" />}
|
icon={<SearchIcon color="currentColor" />}
|
||||||
label={t("Search")}
|
label={t("Search")}
|
||||||
exact={false}
|
exact={false}
|
||||||
|
|||||||
Reference in New Issue
Block a user