-
Notifications
You must be signed in to change notification settings - Fork 13
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
Display the help text in the TextareaArray setting #62
Conversation
Without this, it's really hard to know what to enter. This existed before, but it usually had markup. So instead of doing __dangerouslySetInnerHTML={}, enter the markup in the React file, and use other help text if it exists.
It looks like it has to be wp-env in CircleCI.
'genesis-custom-blocks' | ||
) } | ||
</p> | ||
<p className={ helpClass }> |
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.
Before, this help text was in setting.help
, but it has markup.
So instead of doing dangerouslySetInnerHTML={ setting.default }
, this has the markup in the React file.
php/Blocks/Controls/Multiselect.php
Outdated
_x( 'foo : Foo', 'Format for the menu values. option_value : Option Name', 'genesis-custom-blocks' ), | ||
_x( 'bar : Bar', 'Format for the menu values. option_value : Option Name', 'genesis-custom-blocks' ) | ||
), | ||
'help' => '', |
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 is now in the React file.
This is ''
here in PHP to not override the React's component's help markup.
php/Blocks/Controls/Multiselect.php
Outdated
@@ -69,7 +63,7 @@ public function register_settings() { | |||
'label' => __( 'Default Value', 'genesis-custom-blocks' ), | |||
'type' => 'textarea_array', | |||
'default' => '', | |||
'help' => __( 'Enter each default value on a new line.', 'genesis-custom-blocks' ), | |||
'help' => __( 'Each default value on a new line.', 'genesis-custom-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.
To be similar to the other text. I removed this word from the other text to display on 2 lines instead of 3.
* @property {string} help A help value that display in the GCB editor. | ||
* @property {string} type The setting type, like 'width' or 'text', not a data type like boolean. | ||
* @property {*} default The default value. | ||
*/ |
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.
Not related to this PR, but noticed I forgot to give Setting
a @typedef
before.
Hi @dreamwhisper, How does this look? |
Hi @RobStino, |
@kienstra I'm having some trouble with the multiselect. I see this when the block is on the page. Also, no default appears selected. |
Hi @dreamwhisper, |
Hi @dreamwhisper, I'll work on this when GCB tickets get slotted into a sprint 😄 |
There were conflicts in: js/src/edit-block/components/settings/checkbox.js package.json php/Blocks/Controls/Multiselect.php php/Blocks/Controls/Radio.php php/Blocks/Controls/Select.php tests/php/Unit/Blocks/Controls/TestMultiselect.php tests/php/Unit/Blocks/Controls/TestRadio.php tests/php/Unit/Blocks/Controls/TestSelect.php In almost all cases, resolve conflicts in favor of this branch: add/choices-description. Expect in package.json.
ControlSetting doesn't have a ->sanitize or ->validate property anymore. So no need to pass that. These settings are saved in React, and are not validated.
If the field no longer exists, there's no need to add it to the block's attributes.
There's a new package that was just released 3 days ago.
This reverts commit a344c51.
Without this, <ServerSideRender> could have a network error.
The attribute could be of a different type. For example, changing from a Url field to Image, the type will change from from string to integer. So this prevents an error in ServerSideRender.
The server-side will only have the saved post values. So pass the saved previewAttributes, not just the edited ones. This looks to prevent errors in <ServerSideRender>.
@@ -109,10 +109,7 @@ const Header = ( { editorMode, setEditorMode } ) => { | |||
</button> | |||
<div id="save-and-publish"> | |||
<span className="mr-3 text-sm"> | |||
<PostSavedState | |||
forceIsDirty={ false } | |||
forceIsSaving={ false } |
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.
These are essentially false
by default. So no need to pass false
.
If there is nothing saved, there will be nothing to preview.
Maybe if this were more effortless, it would allow them to click a <button> to do that.
Some blocks won't have fields, just a template.
foo : Foo | ||
</p> | ||
<p className={ helpClass }> | ||
bar : Bar |
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.
Intentionally not translated
It looks like this was a real failure: one of the issues was a deletion of something that didn't exist.
This will look for a combobox (select) with a lable, as that's more like what a user would look for.
… adds that dir When e2e tests fail, it looks like it uses that to add a screenshot.
* | ||
* @return {React.ReactElement} The editor preview. | ||
*/ | ||
const EditorPreview = () => { |
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 file is mainly extracted out of editor.js
* | ||
* @return {React.ReactElement} The front-end preview. | ||
*/ | ||
const FrontEndPreview = () => { |
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 file is mainly extracted from editor.js
, with some conditionals in case there's nothing to preview.
_x( 'foo : Foo', 'Format for the menu values. option_value : Option Name', 'genesis-custom-blocks' ), | ||
_x( 'bar : Bar', 'Format for the menu values. option_value : Option Name', 'genesis-custom-blocks' ) | ||
), | ||
'help' => '', |
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 is now rendered in React.
newAttributes is actually a key/value pair, I think.
These should be saved as a string[], not as an array of objects, like before.
* @param {TextareaDefaultProps} props The component props. | ||
* @return {React.ReactElement} The textarea default component. | ||
*/ | ||
const TextareaDefault = ( { handleOnChange, setting, value } ) => { |
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 component should fix the problem with the Multiselect error. It saves the default value as an array of strings, instead of the array of objects it did before.
Hi @dreamwhisper, Could you please test it again? The multiselect issue looks to be fixed in my local. Thanks, Jen! |
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.
Looks good!
Thanks so much, Jen!!! |
(Testing instructions still valid as of May 5th)
Before
After
Changes
<textarea>
settings in Multiselect, Select, and Radio fieldsTesting instructions
composer install && npm install && npm run dev
/wp-admin
> Custom Blocks > Add New