Skip to content

Commit 121903e

Browse files
authored
Merge pull request #2900 from leeagustin/allow-strings-in-layout-list
Allow strings in layout list
2 parents f0d1645 + a5b13c6 commit 121903e

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1313
- [#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).
1414
- [#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)
1515
- [#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)
16+
- [#2900](https://github.com/plotly/dash/pull/2900) Allow strings in layout list. Fixes [#2890](https://github.com/plotly/dash/issues/2890)
1617
- [#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)
1718

1819
## [2.17.1] - 2024-06-12

dash/_validate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,13 @@ def _validate_id(comp):
439439

440440
if isinstance(layout_value, (list, tuple)):
441441
for component in layout_value:
442+
if isinstance(component, (str,)):
443+
continue
442444
if isinstance(component, (Component,)):
443445
_validate(component)
444446
else:
445447
raise exceptions.NoLayoutException(
446-
"List of components as layout must be a list of components only."
448+
"Only strings and components are allowed in a list layout."
447449
)
448450
else:
449451
_validate(layout_value)

tests/integration/test_integration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ def test_inin028_layout_as_list(dash_duo):
433433
app = Dash()
434434

435435
app.layout = [
436+
"string1",
437+
"string2",
436438
html.Div("one", id="one"),
437439
html.Div("two", id="two"),
438440
html.Button("direct", id="direct"),
@@ -458,6 +460,9 @@ def on_nested_click(n_clicks):
458460

459461
dash_duo.start_server(app)
460462

463+
dash_duo.wait_for_contains_text("#react-entry-point", "string1")
464+
dash_duo.wait_for_contains_text("#react-entry-point", "string2")
465+
461466
dash_duo.wait_for_text_to_equal("#one", "one")
462467
dash_duo.wait_for_text_to_equal("#two", "two")
463468

0 commit comments

Comments
 (0)