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

Add tab blocks to the blocks product editor #37174

Merged
merged 11 commits into from Mar 13, 2023
Merged

Add tab blocks to the blocks product editor #37174

merged 11 commits into from Mar 13, 2023

Conversation

joshuatf
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

This adds a tab block for use in the new product editor that is treated like a normal block. The tab button itself is slotfilled above the editor, while the selected tab is set using context.

This does not address the following, which will be added in follow-up PRs:

  • Accessibility
  • Unit tests
  • Placement within the header (new header has not yet been merged)

Screen Shot 2023-03-10 at 8 55 54 AM

Closes (part of) #37096 .

How to test the changes in this Pull Request:

  1. Check out add/37096-test for initially hydrated sample tab blocks
  2. Make sure that the blocks product editor feature is enabled
  3. Navigate to the add product page
  4. See that the "General" tab is initially selected and the general content is shown
  5. Click "Shipping" and see that the shipping tab is selected and shipping content is shown
  6. Refresh the page (noting &tab=shipping is in the URL) and note that shipping is initially selected
  7. Note that styling is a bit off since the new header is not yet in place, but margin/padding matches the Figma designs

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.

@joshuatf joshuatf requested a review from a team March 10, 2023 17:03
@joshuatf joshuatf self-assigned this Mar 10, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2023

Test Results Summary

Commit SHA: 79dba45

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202611m 9s
E2E Tests189006019516m 18s

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.

@joelclimbsthings joelclimbsthings requested review from joelclimbsthings and removed request for a team March 10, 2023 20:13
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.

Thanks much @joshuatf , and well done. Had a comment or two, and also have this in the console that I'm wondering if we should address:

image

"supports": {
"align": false,
"html": false,
"multiple": false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe having this set to false is giving me this error:

image

I think this should be true ?

That said, this would be true of some of our other blocks such as Section, but that doesn't seem to be giving me the same error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I never ran into this with this block already inserted, but regardless seems like something that should be enabled. Updated in ebfafab


function onClick( tabId: string ) {
window.document.documentElement.scrollTop = 0;
navigateTo( {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice use of this util 👍🏻

"keywords": [ "products", "tab", "group" ],
"textdomain": "default",
"attributes": {
"id": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be useful to have support for disabled via an attribute here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely. Planned for the follow-ups to tabs, but I'd like for us to flesh out how we plan on "templating" different product types.

If we go with individual templates per product type, attributes may work well, but otherwise we may have to build logic directly into the block.

Base automatically changed from add/37082 to trunk March 13, 2023 18:38
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Mar 13, 2023
@joshuatf
Copy link
Contributor Author

Thanks for the feedback, @joelclimbsthings! Addressed the comments.

Had a comment or two, and also have this in the console that I'm wondering if we should address:

I can create a follow-up for this. I don't see this being registered in WC blocks either, but they use the same category 🤔

We might need to double check before adding it to avoid duplicate categories.

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.

Thanks @joshuatf , changes look good and everything is working well. 🚢

@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

Merging #37174 (79dba45) into trunk (0cf5677) will decrease coverage by 0.0%.
The diff coverage is 0.0%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             trunk   #37174     +/-   ##
==========================================
- Coverage     46.7%    46.7%   -0.0%     
  Complexity   17191    17191             
==========================================
  Files          429      429             
  Lines        64845    64862     +17     
==========================================
  Hits         30275    30275             
- Misses       34570    34587     +17     
Impacted Files Coverage Δ
...ugins/woocommerce/includes/class-wc-post-types.php 2.7% <0.0%> (-0.1%) ⬇️

@joshuatf joshuatf merged commit 31ec8d8 into trunk Mar 13, 2023
28 of 30 checks passed
@joshuatf joshuatf deleted the add/37096 branch March 13, 2023 22:00
@github-actions github-actions bot added this to the 7.6.0 milestone Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants