-
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
Background image: add uploading state and restrict drag to one image. #64565
Conversation
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. |
Size Change: +127 B (+0.01%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
Flaky tests detected in 5db40e0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10414375559
|
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.
Thanks, @ramonjd!
The uploading indicator works as expected. The same goes for multiple files error notice.
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.
Overall this is looking great to me! The only issue I ran into is that there is the tiniest of flickers for around 1 frame in the site editor when dragging onto an empty background image button:
Not sure if that's caused by a re-render or remount or something?
Here's a video (it's harder to see in a video):
2024-08-16.14.24.50.mp4
Logic-wise, it looks like you've covered all the cases where the state needs to be updated, and it's a nice and simple approach 👍
if ( isBlobURL( image?.url ) ) { | ||
return; | ||
} |
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 double checking — this can be removed because it's already being handled early on in onSelectMedia
, yeah?
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.
Sorry, I meant to write a note about that. Yeah, the same check is on onSelectMedia
. 👍🏻
@@ -134,6 +134,22 @@ | |||
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); | |||
} | |||
} | |||
|
|||
&.is-uploading { | |||
opacity: 0.5; |
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 out of curiosity (and maybe a question for a designer!), but do we have a consistent level of opacity that we usually set for loading states? At a quick glance, I wasn't able to find much other than 0.2
here:
opacity: 0.2; |
I'm not a designer, but 0.5
in this case is looking visually pleasing to me.
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 also looked around for a consistent color/background/alpha but couldn't find one, hence the random 0.5
.
If there's one, I'm keen to know! 🙇🏻
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.
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.
Maybe we should hide the button label and display the snipper, like the Featured image component at the top.
That would be a lot easier!
The placeholder background comes with a #fff
background so I'll just switch off opacity.
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.
Thanks for testing, people!
Oh, I missed that. I see it now. I'll see if I can fix it.... 🤔 |
@@ -392,7 +411,14 @@ function BackgroundImageControls( { | |||
<div | |||
ref={ replaceContainerRef } | |||
className="block-editor-global-styles-background-panel__image-tools-panel-item" | |||
clsx={ |
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 just invented a new React prop clsx
Might have been related to my eyesight 🤦🏻
Kapture.2024-08-16.at.14.54.47.mp4 |
Oh, really? It's looking good to me, now... I wonder if we're seeing it intermittently, then? |
It looks good in my tests as well. If there's a position shift, it's not noticeable anymore. I even tested with CPU throttling :) |
Thanks again 🙇🏻 Since it's a small change I'll get it in and tweak colors/UI as necessary later. |
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.
Since it's a small change I'll get it in and tweak colors/UI as necessary later.
Sounds good 👍
What?
This PR refines the background image upload flow by:
Why?
Because there's a potential delay when uploading an image, a loading spinner says to users on slow connections that the editor is doing something.
Currently, it's possible to drag 1+ images onto the background control. Background images — at least for now — only support one image.
How?
Testing for media blob, indicating a file upload, to trigger the loading spinner.
Checking the dropped files fileList length.
Testing Instructions
Dragging
Kapture.2024-08-16.at.13.50.56.mp4
Loading
You can emulate slow connections in browsers by throttling the network in the console tools.
Switch the connection to 3g or something slow and try to upload a background image.
Check that the loading spinner appears and disappears as expected.
Kapture.2024-08-16.at.14.59.23.mp4