-
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
Revert Site Tagline placeholder attribute, move example to block.json #48383
Revert Site Tagline placeholder attribute, move example to block.json #48383
Conversation
Size Change: -18 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in 42d94dc. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4257422541
|
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.
Code looks good! and it works well in testing, both with the custom placeholder and with an existing tagline.
"textAlign": { | ||
"type": "string" | ||
} | ||
}, | ||
"example": {}, |
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.
So is this the new canonical way to set block examples or are they only added to block.json
for certain cases? All the ones I can see in trunk seem to be dynamic blocks.
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 reviewing! I wasn't too sure what's the preferred approach, they both seem to work, and I was mostly copying from the example over in #48326. However, the reason I'd included example
in index.js
originally is that we can wrap any strings in translation calls, so that might be a reason why many of them use index.js
instead (e.g. Buttons block's example has strings for the text attribute, etc)
@ntsekouras do you have a preference for where example
goes?
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 think is better to have properties in block.json
, when we can. There have been a lot of work from @gziolo in this area.
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.
You can't express everything in block.json
with the example
field, e.g. translatable strings. I don't know whether I have a preference here.
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.
Thank you, @andrewserong!
No worries, thanks for the reviews! |
Nice work getting a quick change in @andrewserong 👍 |
…#48383) * Revert Site Tagline placeholder attribute, move example to block.json * Remove from docs * Fix bad commit
I just cherry-picked this PR to the wp/6.2 branch to get it included in the next release: b8ecf22 |
What?
Revert Site tagline block's
placeholder
attribute as requested in this review comment: #48300 (comment)Why?
The concern is that introducing a new attribute just for the preview state is not worth the future support or deprecation work should there be changes in the future. Also, reverting appears to be pretty safe, and doesn't prevent us from exploring adding back in some form of custom placeholder info in a future PR if there's feedback about the
Write site tagline...
text being confusing.How?
placeholder
attribute and code that was introduced in Site Tagline: Add example so that it will display in style book #48300example
so that it follows the approach from [Block Library - Site Tagline]: Add example in block settings #48326Note: since the
placeholder
attribute never affects any markup saved to post content (and this is a server-rendered block), we don't have to worry about deprecations.Testing Instructions
Test markup:
<!-- wp:site-tagline {"placeholder":"My custom placeholder..."} /-->
Testing steps:
My custom placeholder...
Write site tagline…
placeholder text should be shown instead, and there should be no errors in the console. If you go to the code editor view, theplaceholder
attribute should no longer be present.Write site tagline...
placeholder should show (or if you have a Site Tagline set, then the current text should be displayed in the preview)Screenshots or screencast