Media Editor Modal: Add custom datetime view for the sidebar to ensure minimal display of dates#78265
Conversation
…e minimal display of dates
|
Size Change: +118 B (0%) Total Size: 7.95 MB 📦 View Changed
ℹ️ View Unchanged
|
| const formFields = useMemo( | ||
| () => | ||
| fields.map( ( field: Field< Media > ) => | ||
| field.type === 'datetime' && field.readOnly | ||
| ? { ...field, render: SidebarDatetimeView } | ||
| : field | ||
| ), | ||
| [ fields ] | ||
| ); |
There was a problem hiding this comment.
Makes sense to have an exception to @wordpress/media-fields date field if it's just for this context.
There was a problem hiding this comment.
Cheers! I figure this is the safest way to go about it. We can always look at a more complex change (or updating the fields themselves) if we find that we'd like this logic in other places, too.
|
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. |
|
Flaky tests detected in d56eda9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25838611690
|


What?
Part of:
In the experimental Media Editor Modal swap out datetime fields' rendering to use a compact form that just shows the date, with the full datetime available on hover.
Why?
Currently, the date added field has a tendency to wrap. Not always, but depending on the particular date and time it can extend just beyond the available room for it visually. To tidy this up, I thought we could try just showing the date, but revealing the full string on hover. This is similar to how it's dealt with in Github.
The reason I went with this approach is that I believe we want an opinionated rendering of datetime strings for this particular UI, rather than to change the fields themselves. This ensures that in the full media library or media upload modal, we continue to render the full datetime string, which is important when it comes to sorting data of many media items.
How?
SidebarDatetimeViewcomponentTesting Instructions
Screenshots or screencast
Media Editor Modal (simplified string with full string available on hover)
Media Upload Modal (still uses the full string)
Use of AI Tools
Claude Code