-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Site Logo: Prevent focus loss when updating media from the sidebar #68621
Conversation
renderToggle={ ( props ) => ( | ||
<Button { ...props } __next40pxDefaultSize> | ||
{ temporaryURL ? ( | ||
<Spinner /> | ||
) : ( | ||
props.children | ||
) } | ||
</Button> |
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.
Fixes spacing inconsistency with the button. See #68084.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
const { | ||
alt_text: alt, | ||
source_url: logoUrl, | ||
slug: logoSlug, | ||
media_details: logoMediaDetails, | ||
} = mediaItemData; | ||
} = media ?? {}; |
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.
The media
can be null
, where the default parameter isn't used and triggers an error when deconstructing. Using fallback here prevents that.
@@ -530,7 +523,7 @@ export default function LogoEdit( { | |||
name: ! logoUrl ? __( 'Choose logo' ) : __( 'Replace' ), | |||
onSelect: onSelectLogo, | |||
onError: onUploadError, | |||
onRemoveLogo, | |||
onReset: onRemoveLogo, |
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.
Just mapping callback to support prop.
Size Change: -183 B (-0.01%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
mediaItemData={ mediaItemData } | ||
/> | ||
} | ||
popoverProps={ {} } |
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 prop was doing nothing. The popoverProps
is undefined
by default.
Thanks for working on this @Mamaduka I cnn confirm the focus loss no longer occurs. To my understanding this also changes the UI, as in: previously the button opened the media modal dialog directly, and now it opens the dropdown with media modal / upload choices. Is that correct? |
Yes, there's a small change to UI/UX, making it more consistent with similar patterns in the editor. For example, the background image control, which can be enabled via block supports. The feature can be tested via Group block. Screenshot |
I'm all for consistency, just wanted to illustrate the UI change for history. |
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
Thanks, @afercia! |
What?
PR fixes a focus loss bug when media is selected or reset via the sidebar's media panel. I've also simplified the media control composition; it now only uses the
MediaReplaceFlow
component.Why?
Improves accessibility of the component.
Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast
CleanShot.2025-01-13.at.09.03.26.mp4