feat: clicking on tag sets it as active
This commit is contained in:
@@ -51,6 +51,13 @@ const NoteTags = observer(({ application, appState }: Props) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onTagClick = (clickedTag: SNTag) => {
|
||||||
|
const tagIndex = tags.findIndex(tag => tag.uuid === clickedTag.uuid);
|
||||||
|
if (tagsRef.current[tagIndex] === document.activeElement) {
|
||||||
|
appState.setSelectedTag(clickedTag);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const isTagOverflowed = useCallback(
|
const isTagOverflowed = useCallback(
|
||||||
(tagElement?: HTMLButtonElement): boolean | undefined => {
|
(tagElement?: HTMLButtonElement): boolean | undefined => {
|
||||||
if (!tagElement) {
|
if (!tagElement) {
|
||||||
@@ -99,8 +106,8 @@ const NoteTags = observer(({ application, appState }: Props) => {
|
|||||||
appState.activeNote.setOverflowedTagsCount(count);
|
appState.activeNote.setOverflowedTagsCount(count);
|
||||||
}, [appState.activeNote, isTagOverflowed]);
|
}, [appState.activeNote, isTagOverflowed]);
|
||||||
|
|
||||||
const setTagsContainerExpanded = (expanded: boolean) => {
|
const expandTags = () => {
|
||||||
appState.activeNote.setTagsContainerExpanded(expanded);
|
appState.activeNote.setTagsContainerExpanded(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -144,6 +151,7 @@ const NoteTags = observer(({ application, appState }: Props) => {
|
|||||||
tagsRef.current[index] = element;
|
tagsRef.current[index] = element;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
onClick={() => onTagClick(tag)}
|
||||||
onKeyUp={(event) => {
|
onKeyUp={(event) => {
|
||||||
if (event.key === 'Backspace') {
|
if (event.key === 'Backspace') {
|
||||||
onTagBackspacePress(tag);
|
onTagBackspacePress(tag);
|
||||||
@@ -173,9 +181,7 @@ const NoteTags = observer(({ application, appState }: Props) => {
|
|||||||
type="button"
|
type="button"
|
||||||
className={`${tagClass} pl-2 absolute`}
|
className={`${tagClass} pl-2 absolute`}
|
||||||
style={{ left: overflowCountPosition }}
|
style={{ left: overflowCountPosition }}
|
||||||
onClick={() => {
|
onClick={expandTags}
|
||||||
setTagsContainerExpanded(true);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
+{overflowedTagsCount}
|
+{overflowedTagsCount}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user