oakes / Nightlight

An embedded editor for Clojure
https://sekao.net/nightlight/
The Unlicense
788 stars 35 forks source link

`400` when clicking on directory nodes in sidebar #37

Closed chpill closed 7 years ago

chpill commented 7 years ago

Clicking on file node in the side bar triggers a POST /write-state and a POST /read-file, and then displays the file in the editor which is good.

Unfortunately, when clicking on a directory node (anywhere else but the button), it also triggers those 2 requests. The POST /read-file immediately fails with a 400. The POST /write-state succeeds, and stores the in the :selection a path that cannot be displayed in the editor (thus, when reloading the page, it will trigger again the faulty POST /read-file.

I guess there are 2 separate concerns here. First clicking anywhere on the directory node in the side-bar should trigger the fold/unfold behavior (limited to the button right now). Second, the server (maybe also the client) should validate the data before writing the .nightlight.edn file.

Anyway, thanks a lot for this awesome editor! I'll try to use it to teach people clojure and it's interactive way of programming.

oakes commented 7 years ago

I'm not sure why it is a problem to have it return an error. Right now the frontend decides to hide the editor if an error is returned by read-file. Is it causing any problem UX-wise?

chpill commented 7 years ago

Not really. I dug into this at first because i was wondering why i could not click anywhere on a directory node to open/close it (which is in fact the standard behaviour of the react material ui lib for selectable-lists). When I saw this error I ran with it but realized later it had nothing to do with the first issue...

I guess having http errors when navigating files / directories is okay, but one thing that could trip up developers is that when the .nightlight.edn file is saved with a directory path as selection, every refresh of the page will trigger this same error. Something to keep in mind.

oakes commented 7 years ago

I'll look into validating .nightlight.edn better.