Skip to content

Commit

Permalink
Merge pull request #2900 from leeagustin/allow-strings-in-layout-list
Browse files Browse the repository at this point in the history
Allow strings in layout list
  • Loading branch information
T4rk1n authored Jul 4, 2024
2 parents f0d1645 + a5b13c6 commit 121903e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#2898](https://github.com/plotly/dash/pull/2898) Fix error thrown when using non-existent components in callback running keyword. Fixes [#2897](https://github.com/plotly/dash/issues/2897).
- [#2892](https://github.com/plotly/dash/pull/2860) Fix ensures dcc.Dropdown menu maxHeight option works with Datatable. Fixes [#2529](https://github.com/plotly/dash/issues/2529) [#2225](https://github.com/plotly/dash/issues/2225)
- [#2896](https://github.com/plotly/dash/pull/2896) The tabIndex parameter of Div can accept number or string type. Fixes [#2891](https://github.com/plotly/dash/issues/2891)
- [#2900](https://github.com/plotly/dash/pull/2900) Allow strings in layout list. Fixes [#2890](https://github.com/plotly/dash/issues/2890)
- [#2908](https://github.com/plotly/dash/pull/2908) Fix when environment variables are ignored by Dash.run() at runtime. Fixes [#2902](https://github.com/plotly/dash/issues/2902)

## [2.17.1] - 2024-06-12
Expand Down
4 changes: 3 additions & 1 deletion dash/_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,13 @@ def _validate_id(comp):

if isinstance(layout_value, (list, tuple)):
for component in layout_value:
if isinstance(component, (str,)):
continue
if isinstance(component, (Component,)):
_validate(component)
else:
raise exceptions.NoLayoutException(
"List of components as layout must be a list of components only."
"Only strings and components are allowed in a list layout."
)
else:
_validate(layout_value)
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ def test_inin028_layout_as_list(dash_duo):
app = Dash()

app.layout = [
"string1",
"string2",
html.Div("one", id="one"),
html.Div("two", id="two"),
html.Button("direct", id="direct"),
Expand All @@ -458,6 +460,9 @@ def on_nested_click(n_clicks):

dash_duo.start_server(app)

dash_duo.wait_for_contains_text("#react-entry-point", "string1")
dash_duo.wait_for_contains_text("#react-entry-point", "string2")

dash_duo.wait_for_text_to_equal("#one", "one")
dash_duo.wait_for_text_to_equal("#two", "two")

Expand Down

0 comments on commit 121903e

Please sign in to comment.