Closed ZbigniewRA closed 1 year ago
Very good point, thanks for bringing up this issue. I fixed it via e8270e99354cc965dea209a23f60dd5c9000ca57, making sure debounced changes are committed before an onBlur
and before destroying the editor.
Fixed now in v0.17.4
Wow, that was fast. Thanks a lot!
Debounced onChange events in text-mode of this JSON editor cause issues.
Consider a form with a control and a Save button. Normally when we get onBlur on a control we know that editing stopped, and Save button handler can safely access the value.
But since in JSON editor onChange is debounced it can arrive after onBlur. So in Save button handler we can't really know if we see all of user's edits, or not yet. So Save can potentially ignore last edits user has made. Other than adding a sleep in onSave handler we have no way of waiting for completion of user interaction (as onBlur is no longer fit for this purpose).
I think that onBlur should first call onChange immediately if some changes are pending (and cancel the debounced onChange).