Delay callback of input component

Is there a way to delay the callback call for an dcc.Input component? Currently, the callback seems to basically be run for every character entered. Or maybe there’s a away to only run the callback after the user pressed enter?

Yes! See https://github.com/plotly/dash-core-components/pull/326
There’s new props for dcc.Input in dash-core-components==0.35.0.

  • n_submit , The number of times enter was pressed when the component had focus.
  • n_blur , The number of times the component lost focus.

Try using n_submit or n_blur in your function should solve your problem.

4 Likes

You can set debounce = True which will only process the value if enter is pressed or the user clicks elsewhere on the screen.

Where do you type this field for this functionality to kick in? @sparrow

As an input param:

dcc.Input(
    id='min-back',
    type='number',
    value=30,            
    style={'fontSize':28},
    debounce = True
),