添加移动端点击自动关闭侧边栏 (#271)

pull/277/head
h2o2o 2 years ago committed by GitHub
parent 1aa9963e07
commit 315ab94c94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,6 +6,7 @@ import { TAG_REG, LINK_REG } from "../labs/marked/parser";
import * as utils from "../helpers/utils";
import { checkShouldShowMemoWithFilters } from "../helpers/filter";
import toastHelper from "./Toast";
import { closeSidebar } from "../helpers/utils";
import Memo from "./Memo";
import "../less/memo-list.less";
@ -92,7 +93,7 @@ const MemoList = () => {
}, [query]);
return (
<div className="memo-list-container" ref={wrapperElement}>
<div className="memo-list-container" ref={wrapperElement} onClick={closeSidebar}>
{sortedMemos.map((memo) => (
<Memo key={`${memo.id}-${memo.createdTs}-${memo.updatedTs}`} memo={memo} />
))}

@ -5,6 +5,7 @@ import { useAppSelector } from "../store";
import * as utils from "../helpers/utils";
import useToggle from "../hooks/useToggle";
import useLoading from "../hooks/useLoading";
import { closeSidebar } from "../helpers/utils";
import Icon from "./Icon";
import toastHelper from "./Toast";
import showCreateShortcutDialog from "./CreateShortcutDialog";
@ -63,6 +64,7 @@ const ShortcutContainer: React.FC<ShortcutContainerProps> = (props: ShortcutCont
const [showConfirmDeleteBtn, toggleConfirmDeleteBtn] = useToggle(false);
const handleShortcutClick = () => {
closeSidebar();
if (isActive) {
locationService.setMemoShortcut(undefined);
} else {

@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
import { useAppSelector } from "../store";
import { locationService, memoService, userService } from "../services";
import useToggle from "../hooks/useToggle";
import { closeSidebar } from "../helpers/utils";
import Icon from "./Icon";
import "../less/tag-list.less";
@ -69,7 +70,7 @@ const TagList = () => {
}, [tagsText]);
return (
<div className="tags-wrapper">
<div className="tags-wrapper" onClick={closeSidebar}>
<p className="title-text">{t("common.tags")}</p>
<div className="tags-container">
{tags.map((t, idx) => (

@ -134,3 +134,8 @@ export const parseHTMLToRawText = (htmlStr: string): string => {
const text = tempEl.innerText;
return text;
};
export function closeSidebar() {
const sidebarEl = document.body.querySelector(".sidebar-wrapper") as HTMLDivElement;
sidebarEl.style.display = "none";
}

Loading…
Cancel
Save