openmct icon indicating copy to clipboard operation
openmct copied to clipboard

Clicking trash while editing a notebook entry saves the notebook entry

Open davetsay opened this issue 1 year ago • 1 comments

Summary

Notebooks are being saved on blur, and the click isn't bubbling up (down?) to the trash icon, so clicking the trash button while editing just saves the notebook entry. Edit: This is only happening on the latest notebook entry. On earlier entries clicking the trash icon prompts the user to confirm deletion of the entry.

Expected vs Current Behavior

Either the trash icon should be disabled or hidden when editing, or clicking the trash can should prompt user to delete the current entry as it does when not editing.

Workaround

Trash the entry after its saved

Steps to Reproduce

  1. create a notebook
  2. create a new entry
  3. click on the trash icon
  4. observe that the entry gets saved

Environment

  • Open MCT Version:
  • Deployment Type:
  • OS:
  • Browser:

Impact Check List

  • [ ] Data loss or misrepresented data?
  • [ ] Regression? Did this used to work or has it always been broken?
  • [ ] Is there a workaround available?
  • [ ] Does this impact a critical component?
  • [ ] Is this just a visual bug with no functional impact?
  • [ ] Does this block the execution of e2e tests?
  • [ ] Does this have an impact on Performance?

Additional Information

davetsay avatar Mar 28 '24 21:03 davetsay

Successfully reproduced error. Details below.

The notebook code has been updated with the following new behavior:

  1. When a notebook entry is in edit mode, the trashcan is not visible.
  2. A new "Escape" shortcut key has been implemented to back-out of entry creation/editing.
  3. A new "Control+Enter" shortcut key has been implemented to save an entry while focus is on the textarea.

Associated PR: https://github.com/nasa/openmct/pull/7991

Details: The existing logic is that when focus is removed from the text area, the entry is automatically committed/saved. Therefore by clicking the trashcan icon, you're removing focus from the textarea which is why your entry is saving. The checkmark "save" button is just a dummy button that does nothing. So when you go to click that, just like with the trashcan button, focus is removed from the textarea and the content is auto-saved giving the appearance that clicking the checkmark button actually did something.

Based on my digging around, I suspect this auto-save behavior is based on an internal requirement (ie: folks didn't want to lose what they typed in an entry if they navigated away from the notebook without saving). So rather than disabling/removing auto-save, I instead decided to remove the trashcan icon when a notebook entry is in edit mode. So in order to cancel your editing, simply press the ESCAPE key and (1) a new entry will disappear, or (2) an existing entry will revert back to its previous value.

ghost avatar Jan 22 '25 05:01 ghost