Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: dark mode tag selection and suggestion (#3004)

Xylit552635562104
diff --git a/web/src/components/MemoEditor/Editor/TagSuggestions.tsx b/web/src/components/MemoEditor/Editor/TagSuggestions.tsx
index f236c265a..35fdf7635 100644
--- a/web/src/components/MemoEditor/Editor/TagSuggestions.tsx
+++ b/web/src/components/MemoEditor/Editor/TagSuggestions.tsx
@@ -75,11 +75,17 @@ const TagSuggestions = ({ editorRef, editorActions }: Props) => {
};
const handleInput = () => {
- if (!editorRef.current) return;
+ const editor = editorRef.current;
+ if (!editor) return;
+
select(0);
const [word, index] = getCurrentWord();
- const isActive = word.startsWith("#") && !word.slice(1).includes("#");
- isActive ? setPosition(getCaretCoordinates(editorRef.current, index)) : hide();
+ const currentChar = editor.value[editor.selectionEnd];
+ const isActive = word.startsWith("#") && currentChar !== "#";
+
+ const caretCordinates = getCaretCoordinates(editor, index);
+ caretCordinates.top -= editor.scrollTop;
+ isActive ? setPosition(caretCordinates) : hide();
};
const listenersAreRegisteredRef = useRef(false);
@@ -106,7 +112,7 @@ const TagSuggestions = ({ editorRef, editorActions }: Props) => {
onMouseDown={() => autocomplete(tag)}
className={classNames(
"rounded p-1 px-2 w-full truncate text-sm dark:text-gray-300 cursor-pointer hover:bg-zinc-200 dark:hover:bg-zinc-800",
- i === selected ? "bg-zinc-300 dark:bg-zinc-700" : "",
+ i === selected ? "bg-zinc-300 dark:bg-zinc-600" : "",
)}
>
<OverflowTip>#{tag}</OverflowTip>