fix: fix focus on previous tag after tag deletion
This commit is contained in:
@@ -28,14 +28,8 @@ export const NoteTag: FunctionalComponent<Props> = ({ appState, tag }) => {
|
||||
const [closeOnBlur] = useCloseOnBlur(contextMenuRef, setContextMenuOpen);
|
||||
useCloseOnClickOutside(contextMenuRef, setContextMenuOpen);
|
||||
|
||||
const deleteTag = async () => {
|
||||
await appState.activeNote.removeTagFromActiveNote(tag);
|
||||
const previousTag = appState.activeNote.getPreviousTag(tag);
|
||||
|
||||
if (previousTag) {
|
||||
const previousTagElement = appState.activeNote.getTagElement(previousTag);
|
||||
previousTagElement?.focus();
|
||||
}
|
||||
const deleteTag = () => {
|
||||
appState.activeNote.removeTagFromActiveNote(tag);
|
||||
};
|
||||
|
||||
const onTagClick = () => {
|
||||
|
||||
@@ -203,10 +203,15 @@ export class ActiveNoteState {
|
||||
async removeTagFromActiveNote(tag: SNTag): Promise<void> {
|
||||
const { activeNote } = this;
|
||||
if (activeNote) {
|
||||
const previousTag = this.getPreviousTag(tag);
|
||||
await this.application.changeItem(tag.uuid, (mutator) => {
|
||||
mutator.removeItemAsRelationship(activeNote);
|
||||
});
|
||||
this.application.sync();
|
||||
if (previousTag) {
|
||||
const previousTagElement = this.getTagElement(previousTag);
|
||||
previousTagElement?.focus();
|
||||
}
|
||||
this.reloadTags();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user