Repository navigation
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 🔴 Action required: Please add missing changelog entries for the following projects: Use the Jetpack CLI tool to generate changelog entries by running the following command: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
| const labelBlockType = getBlockType( 'jetpack/label' ); | ||
| const defaultLabel = labelBlockType.attributes.label.default; |
There was a problem hiding this comment.
This bit confused me, as the default value of the label block's label attribute is an empty string.
It seems like there's no need to pass it through.
| const { attributes, clientId, id, isSelected, label, requiredText, setAttributes } = props; | ||
| const { required, width } = attributes; | ||
| const { attributes, clientId, isSelected, setAttributes } = props; | ||
| const { id, required, requiredText, width } = attributes; |
There was a problem hiding this comment.
There's no attribute called label from what I could see, and I'm also not sure about requiredText 🤔
That's a label block attribute.
There was a problem hiding this comment.
Yeah I think maybe these were simply never updated in this component, as they previously existed on FieldDefaults for all field blocks:
There was a problem hiding this comment.
I've removed requiredText as well.
|
|
||
| const { label, defaultLabel, requiredText } = attributes; | ||
| const defaultPlaceholder = __( 'Add label…', 'jetpack-forms' ); | ||
| const placeholder = emptyToNull( defaultLabel ) ?? emptyToNull( label ) ?? defaultPlaceholder; |
There was a problem hiding this comment.
This is where the bug is that caused the e2e to fail. Anytime the user types in a label, the placeholder gets updated to that label. That includes the aria-label.
Instead the placeholder should stay as something like 'Add label ...' or 'Add option ...'.
| return select( blockEditorStore ).getSettings().isPreviewMode; | ||
| }, [] ); | ||
| const placeholder = __( 'Add label…', 'jetpack-forms' ); | ||
| const placeholderValue = placeholder !== '' ? placeholder : __( 'Add option…', 'jetpack-forms' ); |
There was a problem hiding this comment.
The option block needed a similar fix as the label block.
There was a problem hiding this comment.
I think the option block needs a similar fix.
Isn't this the option block, or did you mean jetpack/options?
I've been testing all blocks and can't see any issues so far with either.
There was a problem hiding this comment.
Yep, I meant this block (option) needs the same fix as the label block.
It doesn't make much sense when I read it back! (edited it now)
ramonjd
left a comment
There was a problem hiding this comment.
Here's how I've been testing:
- In trunk, I created 3 forms (default, outline, animated styles) containing all fields
- I switched to this branch, compared results on the frontend (no regressions)
- In the editor, fiddled with field labels (update/delete).
- Transformed fields
All is working as expected.
I noticed only one regression.
If you remove a label from a field, e.g., name, and then transform it to a select the has-placeholder classname isn't applied in the animated form style. So the label sits in the middle. See the first field in the screenshot. It should look like the second field.
I'll look into it.
| return select( blockEditorStore ).getSettings().isPreviewMode; | ||
| }, [] ); | ||
| const placeholder = __( 'Add label…', 'jetpack-forms' ); | ||
| const placeholderValue = placeholder !== '' ? placeholder : __( 'Add option…', 'jetpack-forms' ); |
There was a problem hiding this comment.
I think the option block needs a similar fix.
Isn't this the option block, or did you mean jetpack/options?
I've been testing all blocks and can't see any issues so far with either.
Nothing to do with this PR. I think it's related to my select transform hack. Carry on! |
ramonjd
left a comment
There was a problem hiding this comment.
Works well in my testing. I also ran the latest commit against the E2E Calypso PR (passed)
✅
|
I think I've addressed all the changes needed. I checked the various patterns and they all work as expected. Transforms are working too. |
Note: merges into #43765 and not trunk
In #43765 it looks like there's some confusion over the concepts of a placeholder and a default label for the label block. This is what caused the tests to fail when there was an initial attempt to merge #42890.
My take on it is that:
placeholdershould be what the label block shows in the editor when there’s no label value.defaultLabelshould be the value of the label when first inserted, and what the label block shows on the frontend when there’s no label.In most cases when the code used an attribute called
defaultLabelit seems like it should have instead been using an attribute calledplaceholder(which wasn't a thing before, but it's being added in this PR to replacedefaultLabel). The placeholder is only shown in the editor and is used for the label block's aria label, so this is used for text like 'Add label...' and 'Add option...'.There are a couple of exceptions:
defaultLabeldifferently, to specify a default value of 'Message' or 'Other Details' for the label (which is not a placeholder).In this PR I try to preserve those, but just pass them through as the
labelvalue rather than keeping a separatedefaultLabelattribute.Fixes #
Proposed changes:
defaultLabelattribute toplaceholderdefaultLabelattribute toplaceholder(it has similar ambiguity)placeholderwhere the code was legitimately passing a placeholder value through to the blockslabelprop.Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: