Skip to content

fix upload style #3251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions components/dash-core-components/src/fragments/Upload.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<LoadingElement id={id}>
<Dropzone
Expand All @@ -79,9 +84,9 @@ export default class Upload extends Component {
rejectClassName={className_reject}
disabledClassName={className_disabled}
style={style}
activeStyle={style_active}
rejectStyle={style_reject}
disabledStyle={style_disabled}
activeStyle={activeStyle}
rejectStyle={rejectStyle}
disabledStyle={disabledStyle}
>
{children}
</Dropzone>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,23 @@ 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() == []