Dash: bug with dcc.Checklist

Created on 3 Apr 2018  路  4Comments  路  Source: plotly/dash

Hi, just noticed a small issue with dcc.Checklist. When I don't put values, I get a "Error in Layout". However, putting an empty array of values works.

For example this works,

checklist = dcc.Checklist( options=[
        {'label': 'New York City0', 'value': 'NYC0' },
        {'label': 'New York City1', 'value': 'NYC1' },
        {'label': 'New York City2', 'value': 'NYC2' },
        {'label': 'New York City3', 'value': 'NYC3' }
    ],
    values=[] ,#['NYC0', 'NYC1'],   
    labelStyle={'display':'inline-block'} )

this does not,

checklist = dcc.Checklist( options=[
        {'label': 'New York City0', 'value': 'NYC0' },
        {'label': 'New York City1', 'value': 'NYC1' },
        {'label': 'New York City2', 'value': 'NYC2' },
        {'label': 'New York City3', 'value': 'NYC3' }
    ],
    labelStyle={'display':'inline-block'} )
dash-meta-good_first_issue dash-type-bug help wanted

Most helpful comment

I think the bug is that putting an empty list does not report "Error in Layout"

No, values=[] should mean that "no checkbox is selected".

I believe that values=[] as defaultProps should indeed fix the issue.

All 4 comments

Hey! I'd like to take this up. Where exactly is the dcc.Checklist defined?
New here, any help and guidance would be appreciated!

@chriddyp Just adding Values to the defaultProps should work right?

@shreyasbapat I'm not sure if the above PR solves that issue. I think the bug is that putting an empty list _does not_ report "Error in Layout". Because as per the inline comments in Checklist.propTypes at dash-core-components/src/components/Checklist.react.js

 /**
             * The value of the checkbox. This value
             * corresponds to the items specified in the
             * `values` property.
             */
value: PropTypes.string,

From what I understand, every entry specified by the value attribute should be one of the entries in values. In which case, passing an empty list to values is still an error. If not then the inline comment needs to be changed.

@chriddyp can you please clarify?

I think the bug is that putting an empty list does not report "Error in Layout"

No, values=[] should mean that "no checkbox is selected".

I believe that values=[] as defaultProps should indeed fix the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexcjohnson picture alexcjohnson  路  3Comments

AngusCui picture AngusCui  路  3Comments

T4rk1n picture T4rk1n  路  3Comments

jwhendy picture jwhendy  路  3Comments

ncdingari picture ncdingari  路  4Comments