A .render() cancels cell edit, user loses entered text

Tags: #<Tag:0x00007efc62102a88> #<Tag:0x00007efc62102948>

We have an issue where the user is kicked out of cell edit when a .render() or a .setDataAtCell() is applied. In our case we put cell changes into a buffer, and send the changes with a small delay to the server, and at that time calculate & display some audit in a table cell using .setDataAtCell(). If this happens while the user edits a cell, the user loses the entered text. We use version 12.1.2

Example: The user wants to type “foo bar”. If the audit with render happens after typing “foo”, that text gets lost, and the user only sees what is typed after that, e.g. only “bar”.

Question: Is there a way to detect if a user is entering and exiting a cell edit? There are two edit modes: 1. typing in a cell to replace content, 2. double click to modify content. We’d need to detect enter & exit of both edit modes. If this is possible I can delay the save and audit until the user exists a cell edit.

Enhancement Request: Do not lose entered text when a .render() or a .setDataAtCell() is applied while in edit mode.

Thanks!

Hi @peter.thoeny

Thank you for contacting us. I think this example might help with the issue: https://jsfiddle.net/handsoncode/mk0ecLn6/ As you can see, it awaits for the user to finish editing the cell if the editor is opened, and only after it’s finished it allows sever to perform another operation.

Thank you Adrian, that looks promising. I will check it out.

What about the enhancement request? I think it would be more intuitive for users to not lose entered text when a .render() or a .setDataAtCell() (other than the cell in edit mode) is applied while in edit mode.

@peter.thoeny

I don’t think that would be possible with the current Handsontable’s structure, as call either of those methods will re-render the whole table. We are aware about this disadvantage and have plans for refactoring this logic, but we don’t have any specific timeline set yet.

Thanks Adrian, makes sense.

~ Peter