Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding prop reorder exceptions #1866

Merged
merged 19 commits into from
Jan 14, 2022
Merged

Adding prop reorder exceptions #1866

merged 19 commits into from
Jan 14, 2022

Conversation

HammadTheOne
Copy link
Contributor

@HammadTheOne HammadTheOne commented Dec 13, 2021

This PR adds an exception conditional for the prop reordering that occurs in py_components_generation.py. Previously, the prop order for certain dcc components and dash-table was changed in the component JS source files, but these changes aren't reflected in the Python backend as props are reordered alphabetically during Python component generation.

With this PR, there is an additional flag for dash-generate-components passed with -k (keep-prop-order). The argument is a comma-separated string of component names which will be exempt from alphabetical prop reordering. The keyword "ALL" can be passed to exempt all components from a particular package.

Closes #1844
Closes #1845
Closes #1840

Contributor Checklist

optionals

  • I have added entry in the CHANGELOG.md

@HammadTheOne
Copy link
Contributor Author

@alexcjohnson This PR should be ready for review now 🙂

@LiamConnors
Copy link
Member

@HammadTheOne, should this address #1840 too? I see it's not mentioned above, so I guess not. I built off this branch and see the following for:

help(dash.dcc.RadioItems)

Output:

RadioItems(options=undefined, id=undefined, value=undefined...x

@@ -17,7 +17,7 @@
"private::build:js": "run-s \"private::build -- --mode production\"",
"private::build:js-test": "run-s \"private::build -- --mode development --config webpack.test.config.js\"",
"private::build:js-test-watch": "run-s \"private::build -- --mode development --config webpack.test.config.js --watch\"",
"private::build:backends": "dash-generate-components src/dash-table/dash/DataTable.js dash_table -p package-info.json && cp dash_table_base/** dash_table/ && dash-generate-components src/dash-table/dash/DataTable.js dash_table -p package-info.json --r-prefix 'dash' --r-suggests 'dash' --jl-prefix 'dash' && black dash_table",
"private::build:backends": "dash-generate-components src/dash-table/dash/DataTable.js dash_table -p package-info.json && cp dash_table_base/** dash_table/ && dash-generate-components src/dash-table/dash/DataTable.js dash_table -p package-info.json -k DataTable --r-prefix 'dash' --r-suggests 'dash' --jl-prefix 'dash' && black dash_table",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make prop order explicit for table, I think we should be a little more careful about what order we end up with, especially since this will be reflected in the docs. The first two are right: data and columns. And it makes sense to keep derived_* and the dash standards (loading_state, persistence) at the end. Other than that it's currently a bit random, will be a bit hard for users to find what they want. @chriddyp do you want to give this a shot?

@@ -25,7 +25,7 @@
"test:pyimport": "python -m unittest tests/test_dash_import.py",
"prebuild:js": "cp node_modules/plotly.js/dist/plotly.min.js dash_core_components_base/plotly.min.js",
"build:js": "webpack --mode production",
"build:backends": "dash-generate-components ./src/components dash_core_components -p package-info.json && cp dash_core_components_base/** dash_core_components/ && dash-generate-components ./src/components dash_core_components -p package-info.json --r-prefix 'dcc' --r-suggests 'dash,dashHtmlComponents,jsonlite,plotly' --jl-prefix 'dcc' && black dash_core_components",
"build:backends": "dash-generate-components ./src/components dash_core_components -p package-info.json && cp dash_core_components_base/** dash_core_components/ && dash-generate-components ./src/components dash_core_components -p package-info.json -k RangeSlider,Slider,DataTable,Dropdown,RadioItems,Checklist --r-prefix 'dcc' --r-suggests 'dash,dashHtmlComponents,jsonlite,plotly' --jl-prefix 'dcc' && black dash_core_components",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here, there are some funny orders that I think we should be more careful about. In Checklist and RadioItems, what's inline doing way at the end, past the dash standards and far from any of the other style props? Some of these are alphabetized, other than the ones we explicitly want upfront, but some aren't - can we be consistent about this?

(BTW DataTable isn't needed in this list 😁)

PropTypes.bool,
PropTypes.arrayOf(PropTypes.bool)
]),
type: PropTypes.oneOf(['any', 'numeric', 'text', 'datetime']),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do nested props also get their order preserved by this PR? If not don't worry about it for now, but assuming at some point they will, let's put type and presentation up top, right below id and name, as these are very important and commonly used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately nested props aren't preserved. For the moment though, I've made the change in d9e386b.

@alexcjohnson
Copy link
Collaborator

We're getting there, looking good!

In the table, let's move row_deletable down a little after row_selectable. Also I think active_cell should go next to the other read-only interaction state props, so perhaps right before selected_cells?

@alexcjohnson
Copy link
Collaborator

Oh actually, re: CheckList - see also my comment above about inline #1866 (comment)

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! 💃

@HammadTheOne HammadTheOne merged commit 0f1b299 into dev Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants