'Python - Dash input box is being reset even on `dash.no_update`

I am creating a web interface based on Dash, where any client can control something on the server.
The web clients are updated regularly based on dcc.Interval callbacks, according to the server data.

One input I need is a regular input box. The user could change the value or if the value is changed remotely the input box should be updated.

But now I'm having the issue that the input box content is reset on each interval callback (even if it returns dash.no_update), making it impossible for the user to type something.

In more detail, this is what happens in order in my code:

  1. New web client is opened
  2. Interval callback is triggered, which will update the content of the input box
  3. On further interval callbacks, the input box is unchanged as the remote value doesn't change (returns the dash.no_update)
  4. The user tries to type inside the input box
  5. On the next timed callback the input box content is reset to the last value

Is there a way to prevent the input value from being touched at all by the timed callback, unless I want to?

EDIT: I found out it's because I am using the debounce option for my dcc.Input. Without this option, the 'unsaved' content of the input is preserved during an update callback. But I do need that debounce feature, since I don't want to process half-entered values.



Solution 1:[1]

It looks like this update callback resets the page to the last state known by Dash, and the with the debounce option these unsaved edits are not registered.

My work around is to avoid the debounce option and instead use n_submit as input, instead of value which I had before:

@app.callback(
    Input("my_input", "n_submit"),
    ...
)
on_submit(...):
    # Internally the `change` event is firing on each keypress, but 
    # only on hitting [Enter] action is taken
    ...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Roberto