diff --git a/apps/web/src/components/dialogs/move-note-dialog.tsx b/apps/web/src/components/dialogs/move-note-dialog.tsx
index 355db3621..4159f3a1e 100644
--- a/apps/web/src/components/dialogs/move-note-dialog.tsx
+++ b/apps/web/src/components/dialogs/move-note-dialog.tsx
@@ -17,7 +17,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-import { ChangeEvent, useCallback, useEffect, useRef, useState } from "react";
+import {
+ ChangeEvent,
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState
+} from "react";
import { Button, Flex, Input, Text } from "@theme-ui/components";
import * as Icon from "../icons";
import { db } from "../../common/db";
@@ -128,6 +135,14 @@ function MoveDialog({ onClose, noteIds }: MoveDialogProps) {
+ {"You have no topics in this notebook."}
+
+ }
isSelected={(item) => {
if (item.type === "notebook") {
return notebook.topics.some((topic) =>
@@ -294,24 +309,34 @@ type TreeNodeProps = {
isSelected: (item: T) => boolean;
onSelected: (item: T) => void;
onCreateItem?: (title: string) => void;
+ placeholder?: JSX.Element;
};
function TreeNode(props: TreeNodeProps) {
- const { isSelected, item, items, onCreateItem, onSelected, sx } = props;
+ const { isSelected, item, items, onCreateItem, onSelected, sx, placeholder } =
+ props;
const [expanded, setExpanded] = useState(false);
const [isCreatingNew, setIsCreatingNew] = useState(false);
+ const _isSelected = useMemo(() => isSelected(item), [item, isSelected]);
return (
{
@@ -337,13 +362,10 @@ function TreeNode(props: TreeNodeProps) {
setIsCreatingNew(false)}
onKeyDown={(e) => {
- e.stopPropagation();
- e.preventDefault();
-
if (e.key === "Enter") {
setIsCreatingNew(false);
onCreateItem?.((e.target as HTMLInputElement).value);
@@ -354,15 +376,17 @@ function TreeNode(props: TreeNodeProps) {
/>
) : null}
- {items?.map((item) => (
- onSelected(item)}
- sx={{ pl: 3 }}
- />
- ))}
+ {items?.length
+ ? items?.map((item) => (
+ onSelected(item)}
+ sx={{ pl: 3 }}
+ />
+ ))
+ : placeholder}
>
) : null}
@@ -376,6 +400,7 @@ type TreeItemProps = {
sx?: ThemeUIStyleObject;
onCreateItem?: (() => void) | null;
testId?: string;
+ isSelected: boolean;
};
function TreeItem(props: TreeItemProps) {
@@ -385,7 +410,8 @@ function TreeItem(props: TreeItemProps) {
onExpand,
title,
sx,
- testId
+ testId,
+ isSelected
} = props;
return (
@@ -394,7 +420,7 @@ function TreeItem(props: TreeItemProps) {
alignItems: "center",
p: "3px",
cursor: "pointer",
- ":hover": { bg: "hover" },
+ ":hover": { bg: isSelected ? "dimPrimary" : "hover" },
justifyContent: "space-between",
...sx
}}