feat: create and add tag to note on hint click
This commit is contained in:
@@ -52,13 +52,19 @@ export const AutocompleteTagInput: FunctionalComponent<Props> = ({
|
|||||||
setSearchQuery(query);
|
setSearchQuery(query);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOptionClick = async (tag: SNTag) => {
|
const onTagOptionClick = async (tag: SNTag) => {
|
||||||
setLockCloseOnBlur(true);
|
setLockCloseOnBlur(true);
|
||||||
await appState.notes.addTagToActiveNote(tag);
|
await appState.notes.addTagToActiveNote(tag);
|
||||||
inputRef.current.focus();
|
inputRef.current.focus();
|
||||||
setLockCloseOnBlur(false);
|
setLockCloseOnBlur(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onTagHintClick = async () => {
|
||||||
|
const newTag = await application.findOrCreateTag(searchQuery);
|
||||||
|
await appState.notes.addTagToActiveNote(newTag);
|
||||||
|
setSearchQuery('');
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={(event) => event.preventDefault()} className="mt-2">
|
<form onSubmit={(event) => event.preventDefault()} className="mt-2">
|
||||||
<Disclosure open={dropdownVisible} onChange={showDropdown}>
|
<Disclosure open={dropdownVisible} onChange={showDropdown}>
|
||||||
@@ -82,7 +88,7 @@ export const AutocompleteTagInput: FunctionalComponent<Props> = ({
|
|||||||
<button
|
<button
|
||||||
key={tag.uuid}
|
key={tag.uuid}
|
||||||
className="sn-dropdown-item"
|
className="sn-dropdown-item"
|
||||||
onClick={() => onOptionClick(tag)}
|
onClick={() => onTagOptionClick(tag)}
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
>
|
>
|
||||||
<Icon type="hashtag" className="color-neutral mr-2" />
|
<Icon type="hashtag" className="color-neutral mr-2" />
|
||||||
@@ -110,6 +116,7 @@ export const AutocompleteTagInput: FunctionalComponent<Props> = ({
|
|||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
className="sn-dropdown-item"
|
className="sn-dropdown-item"
|
||||||
|
onClick={onTagHintClick}
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
Reference in New Issue
Block a user