Forms: incorrect meta appears when resizing Message field
Steps to reproduce
- Create a new page or edit an existing
- Place a Form block - must contain a Message field - the default Contact Form will work
- Hover over the bottom right corner of the field for a few seconds (as though you were resizing the field)
What I expected
For relevant sizing text to appear or no mention of placeholder text while resizing.
What happened instead
The meta text that appears when hovering over the resize option is Set the placeholder text
Browser / OS version
Chrome 86.0.4240.111 / macOS 10.15.7
Screenshot / Video
Here is a video recording of the issue: https://d.pr/v/EhyibX/dy46oPYMyu
The issue seems to lie deeper than just a tooltip that display content that doesn't make sense. Here's a breakdown of what's going on:
Problem 1: Textarea is disabled
<Disabled>
<TextareaControl
placeholder={ placeholder }
value={ placeholder }
onChange={ value => setAttributes( { placeholder: value } ) }
title={ __( 'Set the placeholder text', 'jetpack' ) }
/>
</Disabled>
Looking inside the file https://github.com/Automattic/jetpack/blob/master/extensions/blocks/contact-form/components/jetpack-field-textarea.js., as seen in the snippet above, the <Disabled></Disabled> wrapper around the <TextareaControl> component causes the textarea component to be uneditable. However, there is an onChange event handle attached to it which is supposed to update the placeholder value.
Perhaps the <Disabled></Disabled> tag needs to be removed to allow placeholder to be editable again, but why was the <Disabled></Disabled> tag used in the first place?
There was an overhaul of the contact form in this PR https://github.com/Automattic/jetpack/pull/15362. I suspect this is the point where the placeholder becomes no longer editable.
Problem 2: Title attribute is not so useful
Even if the placeholder is editable, there is no conditional logic to update the title attribute of the textarea. So basically, the title attribute doesn't really serve much of a purpose.
A quick fix, if just targeting the issue reported here, is just to remove the title attribute, or leave it empty.
A proper fix, is to update the title attribute based on the provided placeholder value when problem 1 is fixed.
Problem 3: Entering placeholder value through inspector control is missing
Looking at this issue https://github.com/Automattic/jetpack/issues/12298, it seems that it used to be possible to change the placeholder text of the textarea through the inspector control, but this is no longer there, possibly after the PR https://github.com/Automattic/jetpack/pull/15362 was merged.
Also from the screenshot, it's called "Default value", which sounds rather confusing.
It appears that <JetpackFieldControls> is a wrapper element for where inspector controls lies inside it. Inside the file https://github.com/Automattic/jetpack/blob/master/extensions/blocks/contact-form/components/jetpack-field-controls.js, there is no "Default value" input field to change the placeholder value anymore.
Next Actions
I think all of the problems above are intertwined and they should be tackled together for it to make sense. Of course, the cheap way out is just to set an empty string to the title attribute.
Confirmed this is still present.
Would Jetpack be a better repo for this?
Leaving things open here for now.
This issue is stale because it has been 180 days with no activity. You can keep the issue open by adding a comment. If you do, please provide additional context and explain why you’d like it to remain open. You can also close the issue yourself — if you do, please add a brief explanation and apply one of relevant issue close labels.
I can still replicate this with a self-hosted website. cc @jeherve for a second look about the priority
Doesn't seem to be an issue anymore. Tested Chrome/Safari and there's no Disabled nor title in the component anymore.
https://github.com/Automattic/jetpack/blob/9f11871fd036c7b95869fe63b24ba4c03319ce07/projects/packages/forms/src/blocks/contact-form/components/jetpack-field-textarea.js#L44-L71