-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Open file picker by clicking card #35358
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
Conversation
Test Results SummaryCommit SHA: 43c7366
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
| @@ -0,0 +1,29 @@ | |||
| # FileUploadArea | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I planned to use the FormFileUpload component, but it renders everything inside a button. Since we needed to add another button inside the button, I leaned towards creating our own component to have a clickable area to upload files.
joshuatf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting to review this, but just have a general question on how this should work: should this open the file system's native file picker or the WP media modal to select files?
It's a tiny bit ambiguous to me based on discussion right now, but I would expect the media modal would be opened given that's what happens when clicking the button.
|
Thank you @joshuatf,
From what I understood, the button Maybe @jarekmorawski could confirm whether that's correct or not. |
That's correct! That's why the copy says |
joshuatf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ] ); | ||
| } | ||
| <FormFileUpload | ||
| accept="image/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might need to be updated to account for the allowedMediaTypes prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I changed that in the commit aae35d0
7839d0e to
eddce5d
Compare
|
Hey @joshuatf, Thank you for reviewing this PR.
That error doesn't look related to this PR. It didn't modify any package. I addressed the other changes that you mentioned. Could you take another look at this PR? |
joshuatf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, Fernando! Testing well; left a few comments, but only 1 I think we really need to handle before merging.
| ...files, | ||
| ] ); | ||
| } | ||
| <FormFileUpload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with this here for now, but just curious if we want all media upload components to have the same behavior with file uploading (cc @jarekmorawski).
If so, we could move this into the MediaUploader component. But we can save that for a follow-up if we need to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We should use the same interactions across all media upload components. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could move this into the MediaUploader component. But we can save that for a follow-up if we need to do that.
Good idea. @joshuatf since this PR has been open for so long, I would add that change in a follow-up PR.
| allowedMediaTypes={ [ | ||
| ALLOWED_MEDIA_TYPES, | ||
| ] } | ||
| onError={ () => null } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to this PR but we should probably add some error handling at some point. I'm not sure if @mdperez86 already has an issue open for this or not as I know he implemented some error handling previously.
| .woocommerce-form-file-upload { | ||
| display: flex; | ||
| justify-content: center; | ||
| margin: -4em -2.5em -2.5em; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little hesitant on adding negative margins. This currently goes outside the parent container a bit.
Could we set .components-card__body to 0 padding when there are no images? We'll also need to set the margin on .woocommerce-sortable to 0 when there are no images.
a1e7681 to
981a553
Compare
joshuatf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good and still testing well! 🚢
Can you handle opening a follow-up issue to move the file upload component and styles that we discussed here?
ad9b4fa to
43c7366
Compare
|
Hi @joshuatf, I just rebased this PR and created the issue mentioned in this comment. Could you take another look at this PR? |
AnnaMag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and tests well. 🚢

All Submissions:
Changes proposed in this Pull Request:
This PR adds the code to allow users to open the file picker by clicking anywhere inside the product gallery card.
Closes #35183.
How to test the changes in this Pull Request:
Choose imagesbutton).wcadmin_product_images_add_via_file_upload_areashould be recordedStorybook
Check that the storybook for the component
FileUploadAreais working as expected.Other information:
pnpm --filter=<project> changelog add?FOR PR REVIEWER ONLY: