Skip to content

Conversation

@louwie17
Copy link
Contributor

@louwie17 louwie17 commented Mar 17, 2023

All Submissions:

Changes proposed in this Pull Request:

This adds a new category block that is currently a wrapper around the CategoryField component.
It also adds a new section to the product template.

Initial work on #37263
Note:
There are still some minor styling issues with the Select tree control, which will be done as follow ups:

  • Allow the option to list the options as a comma separated list when list is not expanded.
  • Fix popover location when the dropdown menu doesn't have enough room at the bottom and renders above the input field.
Kapture.2023-03-17.at.15.47.59.mp4

How to test the changes in this Pull Request:

  1. Build this branch and enable the product blocks feature flag: block-editor-feature-enabled
  2. Go to WooCommerce > Products and select a product with categories ( if not create one using the old UI )
  3. The product block editor should load correctly and display a categories field with the selected categories.
  4. You should be able to search for categories, select new ones, and remove current ones (similar to how the current category dropdown works).

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?
  • Have you included testing instructions?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added focus: react admin [team:Ghidorah] package: @woocommerce/components issues related to @woocommerce/components plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Mar 17, 2023
@louwie17 louwie17 requested a review from mdperez86 March 17, 2023 14:58
useLayoutEffect( () => {
if (
selectControlMenuRef.current?.parentElement &&
selectControlMenuRef.current?.parentElement.clientWidth > 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was needed as the block editor seems to render the blocks before they are being displayed on the screen, so this would return a bounding rect with width and height being zero every time.
This condition and the additional dependency below helps with this.

value={ {
selectedTab,
postType: 'product',
postId: product.id,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

exposing the postType and postId in the context as well.

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Merging #37295 (c329a3d) into trunk (c5285ec) will decrease coverage by 5.7%.
The diff coverage is 0.0%.

❗ Current head c329a3d differs from pull request most recent head 14be6cc. Consider uploading reports for the commit 14be6cc to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             trunk   #37295      +/-   ##
===========================================
- Coverage     51.5%    45.8%    -5.7%     
+ Complexity   17283    17196      -87     
===========================================
  Files          430      429       -1     
  Lines        80037    64914   -15123     
===========================================
- Hits         41216    29703   -11513     
+ Misses       38821    35211    -3610     
Impacted Files Coverage Δ
...ugins/woocommerce/includes/class-wc-post-types.php 2.6% <0.0%> (+1.6%) ⬆️

... and 345 files with indirect coverage changes

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2023

Test Results Summary

Commit SHA: 14be6cc

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 51s
E2E Tests1870010019718m 20s

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.

@louwie17 louwie17 force-pushed the add/37263_category_field_block branch 3 times, most recently from c329a3d to 3261a05 Compare March 22, 2023 10:09
@louwie17 louwie17 force-pushed the add/37263_category_field_block branch 2 times, most recently from 2ca8773 to 246c77b Compare April 5, 2023 12:12
@louwie17 louwie17 force-pushed the add/37263_category_field_block branch from 246c77b to 72668b4 Compare April 14, 2023 09:22
@louwie17 louwie17 requested review from a team and removed request for joelclimbsthings, joshuatf and mdperez86 April 14, 2023 09:25
@github-actions
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

@joelclimbsthings joelclimbsthings requested review from joelclimbsthings and removed request for a team April 18, 2023 19:07
Copy link
Contributor

@joelclimbsthings joelclimbsthings left a comment

Choose a reason for hiding this comment

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

Great work @louwie17 , working well and try as I might, I see no issues with the code.

One quick thing--the font for the popover items is 16px, while the design calls for 13px.

Also (likely just me), but if feels a bit weird that if you enter text, and then select an item that came up in search, that the text you entered is still present in the dropdown.

@louwie17
Copy link
Contributor Author

Thanks for the review @joelclimbsthings I have addressed the styling issues.

Also (likely just me), but if feels a bit weird that if you enter text, and then select an item that came up in search, that the text you entered is still present in the dropdown.

Yeah that one may be a preference thing, as this may also cause some weird behaviour if we clear it upon selection, as this would reset the search results while the popover remained open.
I did notice though that the input also remains after closing the popup, which seems a bit odd to me.
I think both of these could be addressed as follow ups though.

Copy link
Contributor

@joelclimbsthings joelclimbsthings left a comment

Choose a reason for hiding this comment

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

Right on, looks good @louwie17 🚢

@louwie17 louwie17 merged commit e88152f into trunk Apr 21, 2023
@louwie17 louwie17 deleted the add/37263_category_field_block branch April 21, 2023 08:10
@github-actions github-actions bot added this to the 7.8.0 milestone Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: @woocommerce/components issues related to @woocommerce/components plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants