diff --git a/CHANGELOG.md b/CHANGELOG.md index 36f866ecd3..6247e0a0d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## Changed - [#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) +## Fixed +- [#3251](https://github.com/plotly/dash/pull/3251). Prevented default styles from overriding `className_*` props in `dcc.Upload` component. + ## [3.0.1] - 2025-03-24 diff --git a/components/dash-core-components/src/fragments/Upload.react.js b/components/dash-core-components/src/fragments/Upload.react.js index 3e9ac0bd34..7bd910c190 100644 --- a/components/dash-core-components/src/fragments/Upload.react.js +++ b/components/dash-core-components/src/fragments/Upload.react.js @@ -64,6 +64,11 @@ export default class Upload extends Component { style_reject, style_disabled, } = this.props; + + const activeStyle = className_active ? undefined : style_active; + const disabledStyle = className_disabled ? undefined : style_disabled; + const rejectStyle = className_reject ? undefined : style_reject; + return ( {children} diff --git a/components/dash-core-components/tests/integration/upload/test_children_accept_any_component.py b/components/dash-core-components/tests/integration/upload/test_children_accept_any_component.py index 87feb352ea..7ee9d9d03c 100644 --- a/components/dash-core-components/tests/integration/upload/test_children_accept_any_component.py +++ b/components/dash-core-components/tests/integration/upload/test_children_accept_any_component.py @@ -28,10 +28,32 @@ def test_upca001_upload_children_gallery(dash_dcc): "textAlign": "center", }, ), + dcc.Upload( + "upload", + disabled=True, + className_disabled="upload-disabled", + id="upload", + ), + dcc.Upload("upload", disabled=True, id="upload-no-className"), ] ) dash_dcc.start_server(app) time.sleep(0.5) dash_dcc.percy_snapshot("upca001 children gallery") + first_child = dash_dcc.find_element("#upload").find_element_by_css_selector( + ":first-child" + ) + # Check that there is no default style since className is specified + style = first_child.get_attribute("style") + assert "opacity: 0.5" not in style + + first_child = dash_dcc.find_element( + "#upload-no-className" + ).find_element_by_css_selector(":first-child") + + # Check that there is default style since no className is specified + style = first_child.get_attribute("style") + assert "opacity: 0.5" in style + assert dash_dcc.get_logs() == []