-
Notifications
You must be signed in to change notification settings - Fork 802
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
External Media: don't show duplicate buttons for post thumbnails #19644
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
@mattwiebe I pushed a change in a327880 (feel free to discard if you don't agree). It didn't seem necessary to add a button when there's no featured image set, so I turned the component into the dropdown trigger |
Found an annoying issue I though we should fix, while we're at it: the media sources dropdown pops back open after you select an external media item. 78b57b5 fixes this by closing the dropdown menu when an item is clicked. |
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.
} | ||
let isPrimary = isFeatured; | ||
let isTertiary = ! isFeatured; | ||
const extraProps = {}; |
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.
Nitpick: maybe this should just be let isSecondary = false;
? I'm not sure I see an advantage to using an object here (unless all the is*
props here are added to it)
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 enjoy nitpicks, and I would overall prefer that, too.
My reasoning is that I was trying to keep the surface area of changes as limited as possible, given the broad and varied use of media buttons throughout different parts of the Gutenberg UI. I wasn't confident that always adding the isSecondary
prop (even set to false
in all non-featured image uses) wouldn't disrupt those other uses.
Now, with a bit more distance, I can see that it will be fine. The prop is false
by default in the Button component and will be in all situations save the "Replace Image" use here. I'll update it that way.
@creativecoder Thanks for the review and improving the PR to boot! I took your nitpick above and appreciate it. |
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.
This tests well for me. 🚢
Previously, our "Select Image" button would still show alongside Core's "Replace Image" button. Now, Cores' button is not shown, and our button shows as "Replace Image" when an image has been selected. Fixes #19555
e4591b0
to
5f10a45
Compare
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.
Confirming this still works after rebase, testing external media extension:
- Featured image adding and removing
- Image block, including replace image flow
- Media and Text block
Great news! One last step: head over to your WordPress.com diff, D60595-code, and commit it. Thank you! |
Previously, our "Select Image" button would still show alongside Core's "Replace Image" button. Now, Cores' button is not shown, and our button shows as "Replace Image" when an image has been selected.
Fixes #19555
Changes proposed in this Pull Request:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
no
Testing instructions:
* With a selected featured image:
Note that we use the Media Button in several locations throughout Gutenberg. These modifications should be isolated to featured image usage, but smoke testing other image-based blocks/settings since I can't find any tests for this.