Skip to content

Commit 858e62f

Browse files
authored
Merge branch 'plotly:dev' into dev
2 parents c470eb3 + f4dda00 commit 858e62f

File tree

8 files changed

+1141
-19
lines changed

8 files changed

+1141
-19
lines changed

.husky/pre-commit

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
npm run lint && \
2-
(cd components/dash-core-components && npm run lint) && \
3-
(cd components/dash-table && npm run lint)
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.lintstagedrc.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// .lintstagedrc.js
2+
const path = require("path");
3+
const fs = require('fs')
4+
5+
// Helper to resolve path to venv executables
6+
const venvBin = (command) => {
7+
let bin = "bin";
8+
if (process.platform == "win32") {
9+
bin = "Scripts";
10+
}
11+
if (fs.existsSync("venv")) {
12+
return path.join("venv", bin, command);
13+
}
14+
if (fs.existsSync(".venv")) {
15+
return path.join(".venv", bin, command);
16+
}
17+
}
18+
19+
module.exports = {
20+
// Python checks (run from root, using root venv)
21+
"*.py": (filenames) => [
22+
`${venvBin("python")} -m pylint --rcfile=.pylintrc ${filenames.join(
23+
" "
24+
)}`, // Add your pylintrc if you have one
25+
`${venvBin("flake8")} ${filenames.join(" ")}`,
26+
`${venvBin("black")} --check ${filenames.join(" ")}`,
27+
],
28+
29+
// ESLint and Prettier for 'components/dash-core-components'
30+
"components/dash-core-components/**/*.{js,jsx,ts,tsx}": (filenames) => {
31+
const relativeFilePaths = filenames.map((f) =>
32+
path.relative(path.join("components", "dash-core-components"), f)
33+
);
34+
return [
35+
`cd components/dash-core-components && npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
36+
" "
37+
)}`,
38+
`cd components/dash-core-components && npx prettier --check ${relativeFilePaths.join(
39+
" "
40+
)}`,
41+
];
42+
},
43+
44+
"components/dash-html-components/**/*.{js,jsx,ts,tsx}": (filenames) => {
45+
const relativeFilePaths = filenames.map((f) =>
46+
path.relative(path.join("components", "dash-html-components"), f)
47+
);
48+
return [
49+
`cd components/dash-html-components && npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
50+
" "
51+
)}`,
52+
];
53+
},
54+
55+
"components/dash-table/**/*.{js,jsx,ts,tsx}": (filenames) => {
56+
const relativeFilePaths = filenames.map((f) =>
57+
path.relative(path.join("components", "dash-table"), f)
58+
);
59+
return [
60+
`cd components/dash-table && npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
61+
" "
62+
)}`,
63+
`cd components/dash-table && npx prettier --check ${relativeFilePaths.join(
64+
" "
65+
)}`,
66+
];
67+
},
68+
69+
"dash/dash-renderer/**/*.{js,jsx,ts,tsx}": (filenames) => {
70+
const relativeFilePaths = filenames.map((f) =>
71+
path.relative(path.join("dash", "dash-renderer"), f)
72+
);
73+
return [
74+
`cd dash/dash-renderer && npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
75+
" "
76+
)}`,
77+
`cd dash/dash-renderer && npx prettier --check ${relativeFilePaths.join(
78+
" "
79+
)}`,
80+
];
81+
},
82+
};

@plotly/dash-test-components/src/components/ExternalComponent.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33

44

5-
const ExternalComponent = ({ id, text, input_id, extra_component }) => {
5+
const ExternalComponent = ({ id, text, input_id, extra_component, extra_component_temp }) => {
66
const ctx = window.dash_component_api.useDashContext();
77
const ExternalWrapper = window.dash_component_api.ExternalWrapper;
8-
98
return (
109
<div id={id}>
1110
{text && <ExternalWrapper
@@ -18,13 +17,15 @@ const ExternalComponent = ({ id, text, input_id, extra_component }) => {
1817
id: input_id
1918
}
2019
}}
21-
componentPath={[...ctx.componentPath, 'external']}
20+
componentPath={[JSON.stringify(ctx.componentPath), 'text']}
21+
temp={true}
2222
/>}
2323
{
2424
extra_component &&
2525
<ExternalWrapper
2626
component={extra_component}
27-
componentPath={[...ctx.componentPath, 'extra']}
27+
componentPath={[...ctx.componentPath, 'props', 'extra_component']}
28+
temp={extra_component_temp}
2829
/>}
2930
</div>
3031
)
@@ -39,6 +40,7 @@ ExternalComponent.propTypes = {
3940
namespace: PropTypes.string,
4041
props: PropTypes.object,
4142
}),
43+
extra_component_temp: PropTypes.bool,
4244
};
4345

4446
export default ExternalComponent;

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
99
- [#3279](https://github.com/plotly/dash/pull/3279) Fix an issue where persisted values were incorrectly pruned when updated via callback. Now, callback returned values are correctly stored in the persistence storage. Fix [#2678](https://github.com/plotly/dash/issues/2678)
1010
- [#3298](https://github.com/plotly/dash/pull/3298) Fix dev_only resources filtering.
1111
- [#3315](https://github.com/plotly/dash/pull/3315) Fix pages module is package check.
12+
- [#3319](https://github.com/plotly/dash/pull/3319) Fix issue where `ExternalWrapper` would remove props from the parent component, now there is a `temp` that is passed to check if it should be removed on unmount.
1213

1314
## Added
1415
- [#3294](https://github.com/plotly/dash/pull/3294) Added the ability to pass `allow_optional` to Input and State to allow callbacks to work even if these components are not in the dash layout.

dash/dash-renderer/src/wrapper/ExternalWrapper.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import {
1313
type Props = {
1414
component: DashComponent;
1515
componentPath: DashLayoutPath;
16+
temp?: boolean; // If true, the component will be removed on unmount.
1617
};
1718

1819
/**
1920
* For rendering components that are out of the regular layout tree.
2021
*/
21-
function ExternalWrapper({component, componentPath}: Props) {
22+
function ExternalWrapper({component, componentPath, temp = false}: Props) {
2223
const dispatch: any = useDispatch();
2324
const [inserted, setInserted] = useState(false);
2425

@@ -33,7 +34,9 @@ function ExternalWrapper({component, componentPath}: Props) {
3334
);
3435
setInserted(true);
3536
return () => {
36-
dispatch(removeComponent({componentPath}));
37+
if (temp) {
38+
dispatch(removeComponent({componentPath}));
39+
}
3740
};
3841
}, []);
3942

0 commit comments

Comments
 (0)