jupytercalpoly/jupyterlab-code-snippets

trying to save an invalid snippet removes all the entered info

ianhi opened this issue · 1 comments

ianhi commented

Describe the bug
If you fill out the snippet form in some invalid way and click save then all your work will be lost.

Peek 2021-02-15 16-39
To Reproduce
Create an invalid snippet info in the dialog and try to save it:

Expected behavior
There are few things I might expect:

  1. The save button is disabled until all fields are valid
  2. Saving pops up a dialog telling you what is wrong but does not remove the info.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Browser Firefox
  • Version 2.0.1

Additional context
I like the way jupyterlab-git handles this:
Peek 2021-02-15 16-43
see e.g. https://github.com/jupyterlab/jupyterlab-git/blob/fd22f2d4c5f34545d6f8dcb3939117ecc73d0e47/src/components/NewBranchDialog.tsx#L208

ianhi commented

It looks like the extension is already doing the check if the input is valid:
image

so I propose using those checks to determine if the save is active or not.