-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Date block HTML is different between front and editor #64699
base: trunk
Are you sure you want to change the base?
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. |
If any additional work is needed I will do it. |
Thank you, @shimotmk! While this fixes the mentioned issue, it breaks markup for linked post-date blocks in templates. You can open a "Single Posts" template in the TT4 theme and check the markup there. Notice that the Maybe we should render a "dummy" cc @richtabor Screenshot |
Thank you for the review! @Mamaduka It seems that the time tag was not rendered when there was no date. Should I fix it so that it is enclosed in the time tag even when there is no date? |
That seems the right way to fix the inconsistency between the editor and the front end. @afercia, any suggestions? Asking because you've worked on similar fixes in the past. |
Thanks for your ping. I'm probably missing something but seems to me the value of the In the editor I get a value of |
@afercia, thanks for spotting that, but the main question here is about markup matching. When the post date is missing, the block will render a placeholder that doesn't match the frontend markup. Should we use "dummy" data (it can be a current date) and generate the correct markup? |
Thanks @Mamaduka
It's not clear to me what is the scenario when the date i missine. Clearer tesing instructions would have helped, Anyways, when a block is 'empty', it should not render anything on the front end. I think the only exception in Gutenberg is an empty paragraph. To me, that is even more important for links. The editor should never render empty links on the front end. I'm not sure a dummy value would be appropriate though? To me, a block that is empty should not render any markup on the front end. I'd also like to see a consistent behavior for all empty blocks. |
When the block is used in templates in the Site Editor context, the date data can be missing. Templates like Single Posts/Pages need to render a placeholder markup since no data for the actual post type is available. So, the question is whether we should try to shim the post date, when it's unavailable for templates and make markup consistent. The block will always render the data on the front end, so we're discussing inconsistency in the Site Editor. Testing Instruction
Screenshot |
@Mamaduka thanks for clarifying. I was misled by the PR description which mentions posts and pages.
Does attempting to provide an accurate preview of the date and its format is even possible? To my understanding, themes can provide their own default format for the Is the Site editor able to get that format and correctly preview it? The default format can be customized in the Inspector so any change to the format should be reflected in the editor preview. Not ethat the 'example date' shown in the inspector is based on some logic to show a 'proper' example I'm not sure I agree with. Also, it doesn't update when changing the format. Fianlly, the post-date can be set to show the modified date. ideally, and only in the context of the Site editor, the block should preview a 'dummy' date that honors the format setting. Not sure that would be easy to achieve. Instead, in the context of the Post editor, I think empty placeholders should render an editing UI and not attempt to render any preview. |
What?
Date block HTML was different between front and editor, so I fixed it.
Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Front
Editor