question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dropdown 'label' doesn't render (seemingly) depending on 'value'

See original GitHub issue

Hi, Possible bug report: Dropdown labels won’t render in the dropdown box if the corresponding ‘value’ for the label is a tuple.

In below example: selecting test_label0 will result in no rendering of test_label0 in the dropdown box. Selecting test_label1 will result in it correctly rending within the dropdown box. Expected behaviour: that label would always render in dropdown irrespective of value value.


# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go

dropdown_options = [
        {'label':'test_label0', 'value':(0,'test_label0')},
        {'label':'test_label1', 'value':1},
        ]

app = dash.Dash()

app.layout = html.Div(children=[
    html.H1(children='dropdown_test'),

    dcc.Dropdown(
        id='dropdown',
        options=dropdown_options,
    )])

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

On OSX, install via pip in conda env:

dash                      0.19.0                    <pip>
dash-core-components      0.15.4                    <pip>
dash-html-components      0.8.0                     <pip>
dash-renderer             0.11.1                    <pip>
dash.ly                   0.17.3                    <pip>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
DBCerigocommented, Jan 19, 2018

@ned2 sorry for the lack of response!

The “bug” (clearly not actually a bug) stopped, and I couldn’t track down what the change was.

But thanks for the response, and right that the issue is now closed 👍

0reactions
ned2commented, Jan 13, 2018

I don’t seem to be able to reproduce this behaviour using your same Dash dependencies. Here’s the code I’m using:

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

dropdown_options = [
    {'label':'test_label1', 'value':'1'},
    {'label':'test_label2', 'value':'2'},
]

app = dash.Dash()

app.layout = html.Div([
    html.H1(children='dropdown_test'),
    dcc.Dropdown(
        id='dropdown',
        options=dropdown_options,
        value='1'
    ),
    html.Div(id='target')
])

@app.callback(Output('target', 'children'), [Input('dropdown', 'value')])
def callback2(value):
    print(type(value))
    return value

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

Note also that you should probably be providing an initial value for value when you initialize the Dropdown, otherwise it will get the value None on each initial page load.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dropdown doesn't show values - Power Platform Community
Dropdown menu that displays values depending on which radio button is pressed. 3. Gallery that is filtered based on what dropdown value user...
Read more >
floating label dropdown not working - Stack Overflow
Im creating a floating label , i manage to make a floating label on textbox but in my dropdown it doesn't work. hope...
Read more >
PowerApps Cascading Dropdown - See comments for 2021 ...
New version available here - https://www.youtube.com/watch?v=SKMwayf_cuMIn today's show, you learn about PowerApps cascading dropdown menus.
Read more >
Populate Dropdown Lists in ASP.NET MVC Razor Views
Building on that functionality, we'll look at how to populate the State/Province/Region dropdown based on the country selected.
Read more >
How To Use Checkboxes In Google Sheets - Ben Collins
A checkbox in Google Sheets has a value TRUE when checked and FALSE ... Any idea on how to dynamically select a checkbox...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found