-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Data View - Page View: Add Featured Image Control #64496
base: trunk
Are you sure you want to change the base?
Conversation
2133ef7
to
0a2c977
Compare
Hey @jameskoster, I've implemented your suggestion: Screen.Capture.on.2024-08-22.at.15-42-51.mp4Let me know if, from the design perspective, there is something to address. I’m not marking this PR as ready for review because we still need to implement the default edit control for the image field. Since DataViews is a general-purpose library, we shouldn’t rely on the WordPress Media Gallery for the generic control. Instead, I suggest using the Operating System’s file selection option: Screen.Capture.on.2024-08-22.at.15-52-20.mp4However, please note that in this case, we won’t have access to the filename once the file is uploaded. |
0a2c977
to
c32622e
Compare
Thanks for the update. The flow seems pretty good, but there are some design details to fix.
Also here:
Here's a mockup that hopefully clarifies some of the details: |
With 9a39fe6, I addressed your feedback! Screen.Capture.on.2024-08-23.at.10-14-17.mp4The only remaining challenge is that the filename can only be truncated to a fixed number of characters, which may result in it not always ending directly under the remove button. |
event.target.tagName.toLowerCase(); | ||
// Prevent opening the media modal when clicking on the button/icon. | ||
if ( | ||
element !== 'button' && | ||
element !== 'svg' | ||
) { |
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 issue is that there's a button within a clickable area, and clicking the button triggers a separate action. I'm not sure if this is the best way to handle 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.
render={ ( { open } ) => { | ||
return ( | ||
<div | ||
role="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.
Related comment: https://github.com/WordPress/gutenberg/pull/64496/files#r1728584779
As I mentioned in the previous comment, this could be complex to achieve given that
Do you mean something like this? |
The documentation says that when ´Limit` is the max number of characters to be displayed: So, if we want to truncate in the middle (so, showing the extension), we need to explicit the max number of characters.
No worries! Gotcha! Thanks! 🙇 |
Thank you, @ntsekouras, for your valuable feedback! I've implemented your suggestion. However, the PR isn't ready for a full review yet, as I plan to explore the solution you proposed here. Currently, the UI/implementation of the generic image field control differs significantly from the control in the One concern with your suggestion is that the existing mockup isn't adaptable for a generic file upload scenario: The current mockup includes two labels:
For a generic file upload handler, only the filename would be available. As you suggested, I will explore of some kind of control config that is passed down, but as I mentioned in the Slack thread, I'm thinking if we we should work on a Sharing my thoughts here as well to help keep this discussion visible! |
I'm going to mark this PR as ready to be reviewed. I'm going to update the description, but overall this PR introduces the Featured Image control following the @jameskoster feedback. The remaining task is to truncate the filename based on the available width. Currently, truncation is performed using a fixed number of characters. Is it something that, is it needed? In the future, this code may be moved to the @wordpress/core-fields-control package if we agree to create it. |
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. |
3e948cc
to
57faa8f
Compare
If this is too problematic we could probably omit the filename for now. Look at the screenshot in your last comment it seems the radius is missing on the thumbnail and the container. We can use |
Thanks for the feedback!
It makes sense! Addressed with 05f0d1a.
Good catch! Fixed with c4db3b9. Screen.Capture.on.2024-09-10.at.14-36-47.mp4 |
label: __( 'Featured Image' ), | ||
getValue: ( { item } ) => item.featured_media, | ||
type: '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.
What is this type
for? This PR provides custom Edit
and render
functions and the type
is not used anywhere I can see.
I see a few options:
- Implement the
image
type for DataForm (with a demo in storybook), like any other types) we support. The advantage is that we can maketype
a required prop to fields. Then, we'd override the Edit control here to use WordPress-specifics. - Implement a custom
feature-image
type that is specific to WordPress, like the slug PR tries to do. - Do not provide any type and just override Edit & render. We'd still need to 1 at some point. It's fine if it's a follow-up.
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 PR has been opened before @wordpress/fields
package and the multiple great conversations that we had during these week. I think that it makes sense to follow the second option. I'm going to move this PR as draft, given that it will require some work before another round of review!
Thanks for the help! 🙇
What?
Part of #64519
This PR adds the Featured Image Control for the Page view.
Screen.Capture.on.2024-09-18.at.18-09-37.mov
View mode
Edit
Additional Changes
Render component and view props
With this PR, the render component will now receive the view prop. This addition is necessary because the component’s layout needs to adapt based on the view. Similar cases include the Title field, where different layouts are required depending on the view.
gutenberg/packages/edit-site/src/components/post-fields/index.js
Lines 163 to 164 in 8356977
Fix error on bulk edit mode
Screen.Capture.on.2024-09-18.at.18-01-00.mp4
Currently, there is an error when the user edits a field in bulk mode. This PR fixes this error.
Attachment type
This PR updates the
Attachment
type.Why?
How?
Testing Instructions
Ensure that
Quick Edit in DataViews
andQuick Edit in DataViews
are enabled.Testing Instructions for Keyboard
Screenshots or screencast