Fix Notebook enter key 6354 (#6365)

* Closes #6354 Notebook Enter key adds new lines
- Removed enter key handlers from Vue component.
- Added "Save" button.
* entry must be selected before editing
* focus on newly created entry
* Closes #6354 Notebook Enter key adds new lines
- Removed enter key handlers from Vue component.
- Added "Save" button.
* do not allow edit unless entry is selected
* remove css for disabled cass

---------

Co-authored-by: David Tsay <david.e.tsay@nasa.gov>
This commit is contained in:
Charles Hacskaylo
2023-03-10 11:00:01 -08:00
committed by GitHub
parent 73734d99ea
commit 39cff51db0
5 changed files with 57 additions and 21 deletions

View File

@@ -25,7 +25,10 @@
<div
class="c-notebook__entry c-ne has-local-controls"
aria-label="Notebook Entry"
:class="{ 'locked': isLocked, 'is-selected': isSelectedEntry }"
:class="{ 'locked': isLocked,
'is-selected': isSelectedEntry,
'is-editing' : editMode
}"
@dragover="changeCursor"
@drop.capture="cancelEditMode"
@drop.prevent="dropOnEntry"
@@ -80,12 +83,17 @@
v-bind.prop="formattedText"
@mouseover="checkEditability($event)"
@mouseleave="canEdit = true"
@mousedown="preventFocusIfNotSelected($event)"
@focus="editingEntry()"
@blur="updateEntryValue($event)"
@keydown.enter.exact.prevent
@keyup.enter.exact.prevent="forceBlur($event)"
>
</div>
<div
v-if="editMode"
class="c-ne__save-button"
>
<button class="c-button c-button--major icon-check"></button>
</div>
</template>
<template v-else>
@@ -454,6 +462,13 @@ export default {
this.$emit('updateEntry', this.entry);
},
preventFocusIfNotSelected($event) {
if (!this.isSelectedEntry) {
$event.preventDefault();
// blur the previous focused entry if clicking on non selected entry input
document.activeElement.blur();
}
},
editingEntry() {
this.editMode = true;
this.$emit('editingEntry');