Skip to content
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

Merged
merged 17 commits into from Jan 29, 2024

Conversation

retrofox
Copy link
Contributor

@retrofox retrofox commented Jan 25, 2024

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:

  1. Go to the Product Editor
  2. Go to the General Tab
  3. Take a look at the summary field
  4. Confirm it looks as expected
  5. Edit the summary content
  6. Confirm it works as expected. Use the alignment and format options provided by the block toolbar
image

Use the React Dev Tool to inspect the block instance

  1. Open the components tab
  2. search instances by TextAreaBlockEdit, which is the react component used to represent the block in the editor dashboard
  3. Confirm the props and attributes are okay
image

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@retrofox retrofox requested a review from a team January 25, 2024 22:29
@retrofox retrofox self-assigned this Jan 25, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 25, 2024
Copy link
Contributor

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:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

github-actions bot commented Jan 25, 2024

Test Results Summary

Commit SHA: 0e90a85

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 37s
E2E Tests289019029912m 26s

⚠️ Warning

Please address the following issues prior to merging this pull request:
  • FAILED/BROKEN TESTS. There were failed and/or broken API and E2E tests.

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

Copy link
Contributor

@mattsherman mattsherman left a 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

"description": "A text-area field for use in the product editor.",
"keywords": [ "products", "description" ],
"textdomain": "default",
"attributes": {
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Comment on lines +68 to +77
<AligmentToolbarButton
align={ align }
setAlignment={ setAlignment }
/>
Copy link
Contributor

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.

Copy link
Contributor Author

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 and rich-text, for instance)

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@retrofox
Copy link
Contributor Author

The toolbar doesn't hide if the focus goes outside of the editor:

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.

@retrofox retrofox force-pushed the update/introduce-text-area-block branch from edf807a to f1aef26 Compare January 29, 2024 11:55
@retrofox
Copy link
Contributor Author

retrofox commented Jan 29, 2024

We should address #43128 form here. (PR reference #43186)

Comment on lines +68 to +77
<AligmentToolbarButton
align={ align }
setAlignment={ setAlignment }
/>
Copy link
Contributor

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.

@mattsherman
Copy link
Contributor

We should address #43128 form here. PR created https://github.com/n2erjo00

I don't think that is the correct link. I also don't see why that should be addressed in this PR.

@retrofox
Copy link
Contributor Author

We should address #43128 form here. PR created https://github.com/n2erjo00

I don't think that is the correct link. I also don't see why that should be addressed in this PR.

updated

Copy link
Contributor

@mattsherman mattsherman left a 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);
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

@retrofox retrofox merged commit 74d0b39 into trunk Jan 29, 2024
41 of 43 checks passed
@retrofox retrofox deleted the update/introduce-text-area-block branch January 29, 2024 20:14
@github-actions github-actions bot added this to the 8.7.0 milestone Jan 29, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jan 29, 2024
@retrofox retrofox mentioned this pull request Jan 29, 2024
@rodelgc rodelgc added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Mothra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants