Skip to content

Commit ef00323

Browse files
authored
Merge pull request #3011 from CNFeffery/dev
Fix #3010 Assigning None to exact or shape array properties causes exception
2 parents 0ff8e4e + d5b70b0 commit ef00323

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
const ArrayOfExactOrShapeWithNodePropAssignNone = (props) => {
5+
const { id, test_array_of_exact_prop, test_array_of_shape_prop } = props;
6+
7+
return (
8+
<div id={id}>
9+
{`length of test_array_of_exact_prop: ${(test_array_of_exact_prop || []).length}, length of test_array_of_shape_prop: ${(test_array_of_shape_prop || []).length}`}
10+
</div>
11+
);
12+
};
13+
14+
ArrayOfExactOrShapeWithNodePropAssignNone.propTypes = {
15+
id: PropTypes.string,
16+
test_array_of_exact_prop: PropTypes.arrayOf(
17+
PropTypes.exact({
18+
label: PropTypes.node,
19+
value: PropTypes.string
20+
})
21+
),
22+
test_array_of_shape_prop: PropTypes.arrayOf(
23+
PropTypes.shape({
24+
label: PropTypes.node,
25+
value: PropTypes.string
26+
})
27+
)
28+
};
29+
30+
export default ArrayOfExactOrShapeWithNodePropAssignNone;

Diff for: @plotly/dash-test-components/src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import DrawCounter from './components/DrawCounter';
1212
import AddPropsComponent from "./components/AddPropsComponent";
1313
import ReceivePropsComponent from "./components/ReceivePropsComponent";
1414
import ShapeOrExactKeepOrderComponent from "./components/ShapeOrExactKeepOrderComponent";
15+
import ArrayOfExactOrShapeWithNodePropAssignNone from './components/ArrayOfExactOrShapeWithNodePropAssignNone';
1516

1617

1718
export {
@@ -27,5 +28,6 @@ export {
2728
DrawCounter,
2829
AddPropsComponent,
2930
ReceivePropsComponent,
30-
ShapeOrExactKeepOrderComponent
31+
ShapeOrExactKeepOrderComponent,
32+
ArrayOfExactOrShapeWithNodePropAssignNone
3133
};

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
77
## Fixed
88

99
- [#2994](https://github.com/plotly/dash/pull/2994) Keep generated doc-string order for shape or exact props. Fixes [#2990](https://github.com/plotly/dash/issues/2990)
10+
- [#3011](https://github.com/plotly/dash/pull/3011) Fixed an exception error caused by assigning `None` to array properties with `exact` or `shape` element types. Fixes [#3010](https://github.com/plotly/dash/issues/3010)
1011

1112
## [2.18.1] - 2024-09-12
1213

Diff for: dash/dash-renderer/src/TreeContainer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class BaseTreeContainer extends Component {
322322
});
323323

324324
node = rpath(frontPath, props);
325-
if (node === undefined || !node.length) {
325+
if (node === undefined || !node?.length) {
326326
continue;
327327
}
328328
const firstNode = rpath(backPath, node[0]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from dash import Dash, html
2+
3+
from dash_test_components import ArrayOfExactOrShapeWithNodePropAssignNone
4+
5+
6+
def test_aoeoswnpsn001_array_of_exact_or_shape_with_node_prop_assign_none(dash_duo):
7+
app = Dash(__name__)
8+
app.layout = html.Div(
9+
[
10+
ArrayOfExactOrShapeWithNodePropAssignNone(
11+
id="test-component1",
12+
test_array_of_exact_prop=[{"label": c, "value": c} for c in "abc"],
13+
test_array_of_shape_prop=[{"label": c, "value": c} for c in "abc"],
14+
),
15+
ArrayOfExactOrShapeWithNodePropAssignNone(
16+
id="test-component2",
17+
test_array_of_exact_prop=None,
18+
test_array_of_shape_prop=None,
19+
),
20+
]
21+
)
22+
23+
dash_duo.start_server(app)
24+
dash_duo.wait_for_text_to_equal(
25+
"#test-component1",
26+
"length of test_array_of_exact_prop: 3, length of test_array_of_shape_prop: 3",
27+
)
28+
dash_duo.wait_for_text_to_equal(
29+
"#test-component2",
30+
"length of test_array_of_exact_prop: 0, length of test_array_of_shape_prop: 0",
31+
)

0 commit comments

Comments
 (0)