Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Input component updates#356

Merged
valentijnnieman merged 13 commits intomasterfrom
input_update
Nov 5, 2018
Merged

Input component updates#356
valentijnnieman merged 13 commits intomasterfrom
input_update

Conversation

@valentijnnieman
Copy link
Contributor

@valentijnnieman valentijnnieman commented Oct 31, 2018

edit:
This PR is becoming much bigger than expected, apologies in advance if the commit history or comments are not super clear.

This updates the Input component with a new debounce prop that determines when setProps is called, should fix #169. It also adds a bunch of unit tests, and fixes an issue where props coming from dash-renderer would overwrite the current state of the input. That last bug is more common than we think - components that use state as well as setProps get out of sync often.

Here's an example app with the new debounce prop:

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.scripts.config.serve_locally = True

app.layout = html.Div([
    dcc.Input(placeholder='Enter a value...',
        type='number',
        value=0,
        step=0.01,
        debounce=True,
        id='input_id',
        style={'float': 'left'}),
    html.Div(id='my-div')
])

@app.callback(
    Output(component_id='my-div', component_property='children'),
    [Input(component_id='input_id', component_property='value')]
)
def update_output_div(input_value):
    return 'You\'ve entered (+1) {}'.format(input_value+1)

if __name__ == '__main__':
    app.run_server()

It also fixes #292 by fixing the step prop and #173 by not updating value if < min or > max.

Also renamed a couple of props that weren't being picked up by React, similarly to #348.

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input type “number” increment bug dcc.Input bug with decimal values

3 participants