Skip to content
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

FIX: ActionButtonItem.disabled not working #28 #29

Merged
merged 2 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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: 9 additions & 2 deletions src/Dropzone/components/DropzoneButtons/DropzoneButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ const DropzoneButtons: React.FC<DropzoneButtonsProps> = (


(actionButtonProps: ActionButtonItem, index: number) => {
const { children, label, resetStyles, className, style, onClick } =
actionButtonProps;
const {
disabled,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property was missing

children,
label,
resetStyles,
className,
style,
onClick,
} = actionButtonProps;
return (
<MaterialButton
key={index}
Expand Down
23 changes: 12 additions & 11 deletions tests/Dropone.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ test("Validate label text must be 'Drop yor files here...'", () => {

describe("Dropzone actionButtons", () => {
test.each([
[{ uploadButton: { onClick: console.log } }, "Upload"],
[{ uploadButton: { label: undefined, onClick: console.log } }, "Upload"],
[{ uploadButton: { label: null, onClick: console.log } }, "Upload"],
[{ uploadButton: { label: "my label", onClick: console.log } }, "my label"],
[{ deleteButton: { label: null, onClick: console.log } }, "Delete"],
[
{ deleteButton: { label: "my delete label", onClick: console.log } },
"my delete label",
],
[{ uploadButton: { onClick: console.log } }, false],
[{ uploadButton: { onClick: console.log, disabled: false } }, false],
[{ uploadButton: { onClick: console.log, disabled: true } }, true],
[{ deleteButton: { onClick: console.log } }, false],
[{ deleteButton: { onClick: console.log, disabled: false } }, false],
[{ deleteButton: { onClick: console.log, disabled: true } }, true],

// abortButton and cleanButton need more interaction
])("label %s -> %s", (config, expected) => {
])("disabled %s -> %s", (config, expected) => {
const { container } = render(
<Dropzone actionButtons={{ position: "after", ...config }} />,
);
expect(
container.querySelector(".files-ui-buttons-container button").textContent,
(
container.querySelector(
".files-ui-buttons-container button",
) as HTMLInputElement
).disabled,
).toBe(expected);
});
});
Loading