plotly / dash-core-components

OBSOLETE: now part of https://github.com/plotly/dash
https://dash.plotly.com
MIT License
270 stars 146 forks source link

dcc.Dropdown not rendering the label when the value is a list #187

Open vincepota-zz opened 6 years ago

vincepota-zz commented 6 years ago

The label of the dropdown does not render when its value is a list. The callback works fine. Running version 0.22.1

import dash
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash()
app.layout = html.Div([
    dcc.Dropdown(
        id='my-dropdown',
        options=[
            {'label': 'Option with a list', 'value': [1,2,3,4]},
            {'label': 'Option with a string', 'value': 'New York'},
            {'label': 'Option with an integer', 'value': 1}
        ],
        value=1
    ),
    html.Div(id='output-container')
])

@app.callback(
    dash.dependencies.Output('output-container', 'children'),
    [dash.dependencies.Input('my-dropdown', 'value')])
def update_output(value):
    return 'The value is a "{}" with value {}'.format(type(value), value)

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

out

ThibTrip commented 4 years ago

Hello, the problem still exists with newer versions. Tested it with dash version 1.2.0 and dash_core_components version 1.1.2. Fails the same way with tuples and numpy arrays.

Code I used ```python import dash import dash_core_components as dcc import numpy as np app = dash.Dash() dd = dcc.Dropdown(options = [{'label': 'apples, bananas', 'value': ['apples', 'bananas']}, {'label': 'apples', 'value': ['apples']}], value = 'apples', style = {'width':'30%'}, id = 'dd') md = dcc.Markdown(id = 'md') app.layout = html.Div([dd,md]) @app.callback(Output('md','children'), [Input('dd', 'value')]) def display_value(value): return value app.run_server(debug = False) # I work with Jupyter so I set debug to False ```