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