fixes to entries (#6464)

* fixes to entries
fix delete first notebook entry
fix select unfocused on create
* do not blur if nothing is focused
This commit is contained in:
David Tsay 2023-03-17 15:14:15 -07:00 committed by GitHub
parent 201c669328
commit 453b1f3009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 9 deletions

View File

@ -236,7 +236,7 @@ export default {
sidebarCoversEntries: false, sidebarCoversEntries: false,
filteredAndSortedEntries: [], filteredAndSortedEntries: [],
notebookAnnotations: {}, notebookAnnotations: {},
selectedEntryId: '', selectedEntryId: undefined,
activeTransaction: false, activeTransaction: false,
savingTransaction: false savingTransaction: false
}; };
@ -381,8 +381,10 @@ export default {
}); });
}, },
updateSelection(selection) { updateSelection(selection) {
if (selection?.[0]?.[0]?.context?.targetDetails?.entryId === undefined) { const keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
this.selectedEntryId = '';
if (selection?.[0]?.[0]?.context?.targetDetails?.[keyString]?.entryId === undefined) {
this.selectedEntryId = undefined;
} }
}, },
async loadAnnotations() { async loadAnnotations() {
@ -522,6 +524,8 @@ export default {
this.openmct.notifications.alert('Warning: unable to delete entry'); this.openmct.notifications.alert('Warning: unable to delete entry');
console.error(`unable to delete entry ${entryId} from section ${this.selectedSection}, page ${this.selectedPage}`); console.error(`unable to delete entry ${entryId} from section ${this.selectedSection}, page ${this.selectedPage}`);
this.cancelTransaction();
return; return;
} }
@ -534,10 +538,15 @@ export default {
emphasis: true, emphasis: true,
callback: () => { callback: () => {
const entries = getNotebookEntries(this.domainObject, this.selectedSection, this.selectedPage); const entries = getNotebookEntries(this.domainObject, this.selectedSection, this.selectedPage);
if (entries) {
entries.splice(entryPos, 1); entries.splice(entryPos, 1);
this.updateEntries(entries); this.updateEntries(entries);
this.filterAndSortEntries(); this.filterAndSortEntries();
this.removeAnnotations(entryId); this.removeAnnotations(entryId);
} else {
this.cancelTransaction();
}
dialog.dismiss(); dialog.dismiss();
} }
}, },

View File

@ -54,7 +54,7 @@
class="c-ne__remove c-icon-button c-icon-button--major icon-trash" class="c-ne__remove c-icon-button c-icon-button--major icon-trash"
title="Delete this entry" title="Delete this entry"
tabindex="-1" tabindex="-1"
@click="deleteEntry" @click.stop.prevent="deleteEntry"
> >
</button> </button>
</span> </span>
@ -466,8 +466,11 @@ export default {
if (!this.isSelectedEntry) { if (!this.isSelectedEntry) {
$event.preventDefault(); $event.preventDefault();
// blur the previous focused entry if clicking on non selected entry input // blur the previous focused entry if clicking on non selected entry input
const focusedElementId = document.activeElement?.id;
if (focusedElementId !== this.entry.id) {
document.activeElement.blur(); document.activeElement.blur();
} }
}
}, },
editingEntry() { editingEntry() {
this.editMode = true; this.editMode = true;