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
[Product Block Editor]: introduce TextArea field block #44104
Conversation
Hi , @woocommerce/mothra Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test Results SummaryCommit SHA: 0e90a85
Please address the following issues prior to merging this pull request: |
2a73a8a
to
d49fd8c
Compare
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.
Nice work on this so far, @retrofox !
Is there a way to get the output to be plain text instead of HTML if no formatting is allowed? There are still <br>
tags.
The toolbar doesn't hide if the focus goes outside of the editor:
Screen.Recording.2024-01-26.at.14.01.24.mov
packages/js/product-editor/src/blocks/generic/text-area/block.json
Outdated
Show resolved
Hide resolved
"description": "A text-area field for use in the product editor.", | ||
"keywords": [ "products", "description" ], | ||
"textdomain": "default", | ||
"attributes": { |
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.
placeholder
isn't listed here, though it is supported.
We should also support (same as woocommerce/product-text-field
):
tooltip
required
disabled
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've added the attributes and types, but probably we need to keep improving these attributes. Can we do it in a follow-up?
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'm cool with a follow-up, but we shouldn't consider the (sorely missing any details 😞) issue closed/fixed until they are added.
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 have updated the pull request so that it doesnt close the issue when merged
packages/js/product-editor/src/blocks/generic/text-area/edit.tsx
Outdated
Show resolved
Hide resolved
packages/js/product-editor/src/blocks/generic/text-area/edit.tsx
Outdated
Show resolved
Hide resolved
<AligmentToolbarButton | ||
align={ align } | ||
setAlignment={ setAlignment } | ||
/> |
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.
We should have a way to turn off the alignment toolbar, as for a plain text textarea, it isn't necessary.
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.
We need to define this functionality a little bit. It isn't clear to me when/how the block should support rich text or plain text areas.
- Is it the same block that changes its behavior depending on a parameter? (block attribute).
- Could this block support both modes? It could be switchable from the block toolbar.
- Or, should we create two different blocks? (
text-area
andrich-text
, for instance)
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.
Could we address this issue in a follow-up, Matt? I want to avoid increasing the PR size.
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'm good if this is addressed in a follow-up. I think we should allow block attributes that allow us to pick between using a plain textarea vs one with rich text.
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 agree that it should be switchable between rich text and plain text via a block attribute. I don't think, for our purposes, it makes sense to have it be switchable from the block toolbar.
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.
packages/js/product-editor/src/blocks/generic/text-area/edit.tsx
Outdated
Show resolved
Hide resolved
Can we address this issue in a follow-up? It isn't part of the implementation. Although it's possible to handle it from the Rich Text instance from the onBlur event I think that's a workaround. |
edf807a
to
f1aef26
Compare
<AligmentToolbarButton | ||
align={ align } | ||
setAlignment={ setAlignment } | ||
/> |
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'm good if this is addressed in a follow-up. I think we should allow block attributes that allow us to pick between using a plain textarea vs one with rich text.
packages/js/product-editor/src/blocks/generic/text-area/block.json
Outdated
Show resolved
Hide resolved
I don't think that is the correct link. I also don't see why that should be addressed in this PR. |
updated |
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.
Nice work. I'm okay with the remaining issues being tackled in follow up PR(s).
.wp-block-woocommerce-product-text-area-field { | ||
.rich-text { | ||
width: 100%; | ||
min-height: calc($gap-larger * 3); |
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.
Seems odd to base the min-height
on the gap instead of something related to the font size.
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.
How do you think we should define the minimum height? Maybe we can use a different var?
min-height: calc($gap-larger * 3); | ||
background-color: $white; | ||
box-sizing: border-box; | ||
border: 1px solid #757575; |
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.
Hardcoded color. It's a shame we don't have a variable for this.
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.
Creating a new var, at least for now, sounds good for you?
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.
ad88986 Here we are using the $gray-700
var.
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR introduces a new Textarea block. This block is used for the Summary product field. In a follow-up were going to update the Description field too.
Part of #42736
Closes
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Use the React Dev Tool to inspect the block instance
Changelog entry
Significance
Type
Message
Comment