This repository was archived by the owner on Jun 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 73
Issue 384 - Handling of None
data and columns props
#731
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b505bf8
`data` and `columns` are required props
299c2c0
changelog
c2d870c
- undo data and columns `isRequired`
0c27fd3
add empty and valid when data=None, columns=None
f47a3d1
Merge remote-tracking branch 'origin/dev' into 384-validate-data-columns
d93331d
- make test more specific
5794b7a
Merge branch 'dev' into 384-validate-data-columns
Marc-Andre-Rivet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import dash | ||
from dash.dependencies import Input, Output | ||
from dash.exceptions import PreventUpdate | ||
|
||
from dash_table import DataTable | ||
from dash_html_components import Button, Div | ||
|
||
|
||
def get_app(): | ||
app = dash.Dash(__name__) | ||
|
||
columns = [{"name": i, "id": i} for i in ["a", "b"]] | ||
data = [dict(a=1, b=2), dict(a=11, b=22)] | ||
|
||
app.layout = Div( | ||
[ | ||
Button(id="clear-table", children=["Clear table"]), | ||
DataTable(id="table", columns=columns, data=data), | ||
] | ||
) | ||
|
||
@app.callback( | ||
[Output("table", "data"), Output("table", "columns")], | ||
[Input("clear-table", "n_clicks")], | ||
) | ||
def clear_table(n_clicks): | ||
if n_clicks is None: | ||
raise PreventUpdate | ||
|
||
nonlocal columns, data | ||
|
||
return (data, columns) if n_clicks % 2 == 0 else (None, None) | ||
|
||
return app | ||
|
||
|
||
def test_empt001_clear_(test): | ||
test.start_server(get_app()) | ||
|
||
target = test.table("table") | ||
|
||
assert target.is_ready() | ||
test.driver.find_element_by_css_selector("#clear-table").click() | ||
assert target.is_ready() | ||
assert len(test.driver.find_elements_by_css_selector("tr")) == 0 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the callback returns, the table should (1) load successfully and get to the ready state, (2) should contain no rows.
TDD'ed locally, can undo redo the fix in the PR if we'd rather have the demonstration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with not seeing the test fail on CI - I assume we're all running our own tests with the fix disabled. But it would be nice to have this test check for the proper number of
<tr>
elements before theclear-table
.Also, given that you have the
is_ready()
method this may not be helpful, but in wildcards I added await_for_no_elements
method