[Beta] Do not update table rows when pressing esc or when they have been modified

It is possible to click on a cell of a column of a row of a table, type a value and update it in the database.
This is great, but it should be prevented in two cases:

  • When the data in the row has changed after it has been last loaded. I’m sure I do want this!
  • When pressing esc. I’m less sure about this

I’m not sure that pressing esc is the right way, but I’m sure there should be a way to abandon the editing without changing the value.

Perhaps pressing enter should do the update and pressing esc should cancel it… but then what do we do when clicking away?

Perhaps there should always be an alert that explicitly ask whether to update?

Perhaps there should be an undo key, which will set the last edited value to its previous value?

In this last case, it should be clear if and what has been undone.

1 Like

This is the way phpMyAdmin handles the same case (it works well).

Anvil’s way of handling this is exceptionally annoying when you create tables to record information that is only generated by back-end systems (like recording a transaction) and you use the logic built into the anvil table system without any way to turn it off (allow null, no you can’t set a default value) that says “If you create a new row, and don’t specify one of the column values, it will be a None value.”

So you write a whole system, it works and you publish it with code that depends on the NULL/None value representing information not gathered.

Now you accidentally click in the data tables box on some None value (even while working in development), and guess what - you can’t put it back the way it was, and the new ‘default’ of whatever you have to put in there is not None and you can’t make it say None from the table browser.

Now your published running system has an out of bounds value that requires that you drop everything and write a new case for whatever default is for “oops I clicked a column of some type”.

/rant off :laughing:

It’s not intuitive, but you can, with the column selected but not editing it, press the delete key to change it to None.

1 Like

Yes to both of those. Editing a stale row is just a bad idea. I don’t know if Anvil has enough information to prevent it, but it’s be real nice if it could.

And the Enter/Esc paradigm is used enough places I think that’d work fine here.

I didn’t know that, thanks.
Even with that, what happens when you lose the row because you don’t even know you clicked a cell until users start complaining.
You have to try and use the gui column sort, and that only works if whatever gets inserted as ‘default’ happens to be first or last however the column gets sorted.

If that fails then you have to write some helper function to find your row.

By then you are back to

being faster than fixing it just for that one time. Either way it’s a scramble to fix a live service.