Skip to content

Commit 0bd4452

Browse files
authored
Merge pull request #3251 from AnnMarieW/fix-upload-style
fix upload style
2 parents 28e8162 + e38cc3a commit 0bd4452

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
77
## Changed
88
- [#3113](https://github.com/plotly/dash/pull/3113) Adjusted background polling requests to strip the data from the request, this allows for context to flow as normal. This addresses issue [#3111](https://github.com/plotly/dash/pull/3111)
99

10+
## Fixed
11+
- [#3251](https://github.com/plotly/dash/pull/3251). Prevented default styles from overriding `className_*` props in `dcc.Upload` component.
12+
1013

1114
## [3.0.1] - 2025-03-24
1215

components/dash-core-components/src/fragments/Upload.react.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export default class Upload extends Component {
6464
style_reject,
6565
style_disabled,
6666
} = this.props;
67+
68+
const activeStyle = className_active ? undefined : style_active;
69+
const disabledStyle = className_disabled ? undefined : style_disabled;
70+
const rejectStyle = className_reject ? undefined : style_reject;
71+
6772
return (
6873
<LoadingElement id={id}>
6974
<Dropzone
@@ -79,9 +84,9 @@ export default class Upload extends Component {
7984
rejectClassName={className_reject}
8085
disabledClassName={className_disabled}
8186
style={style}
82-
activeStyle={style_active}
83-
rejectStyle={style_reject}
84-
disabledStyle={style_disabled}
87+
activeStyle={activeStyle}
88+
rejectStyle={rejectStyle}
89+
disabledStyle={disabledStyle}
8590
>
8691
{children}
8792
</Dropzone>

components/dash-core-components/tests/integration/upload/test_children_accept_any_component.py

+22
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,32 @@ def test_upca001_upload_children_gallery(dash_dcc):
2828
"textAlign": "center",
2929
},
3030
),
31+
dcc.Upload(
32+
"upload",
33+
disabled=True,
34+
className_disabled="upload-disabled",
35+
id="upload",
36+
),
37+
dcc.Upload("upload", disabled=True, id="upload-no-className"),
3138
]
3239
)
3340
dash_dcc.start_server(app)
3441
time.sleep(0.5)
3542
dash_dcc.percy_snapshot("upca001 children gallery")
3643

44+
first_child = dash_dcc.find_element("#upload").find_element_by_css_selector(
45+
":first-child"
46+
)
47+
# Check that there is no default style since className is specified
48+
style = first_child.get_attribute("style")
49+
assert "opacity: 0.5" not in style
50+
51+
first_child = dash_dcc.find_element(
52+
"#upload-no-className"
53+
).find_element_by_css_selector(":first-child")
54+
55+
# Check that there is default style since no className is specified
56+
style = first_child.get_attribute("style")
57+
assert "opacity: 0.5" in style
58+
3759
assert dash_dcc.get_logs() == []

0 commit comments

Comments
 (0)