Unable to update dcc.Input value on callback

Hi!

I’m trying to update the value of a dcc.Input component as the result of a callback, but I’m unable to make it work.

A simplified example that reproduces my issue:

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

# App init
app = dash.Dash(__name__)

# Layout
app.layout = html.Div(children=[
    dcc.Input(
        id='test-input',
        type='text'
    ),

    dcc.Slider(
        id='test-slider',
        min=0,
        max=10,
        value=5
    )
])


@app.callback(Output('test-input', 'value'),
              [Input('test-slider', 'value')])
def update_input(slider_value):
    print('Slider value: {}'.format(slider_value))
    return slider_value


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

Is there something wrong with my code? Or is not possible to have a dcc.Input value as the output of a callback?

Thanks

Looks like a dash bug to me! I’ve created an issue here: https://github.com/plotly/dash-core-components/issues/430

I think the issue is the same as was going on in this post. Your dcc.Input needs to be registered as either an input or a state of at least one callback.

I thought I had documented this in the last item of the Dash Gotchas but that entry isn’t quite right, it claims that having it as an output is sufficient, whereas this example and the other one I linked above suggests that it has to be an input or a state.

Thanks both. I’ve commented in the GitHub issue with a possible workaround.