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

Refactor AttributeField into sub-components #35997

Merged
merged 8 commits into from
Dec 16, 2022

Conversation

mattsherman
Copy link
Contributor

@mattsherman mattsherman commented Dec 15, 2022

All Submissions:

Changes proposed in this Pull Request:

This PR refactors AttributeField into sub-components, where those sub-components expose all UI strings as props, allowing them to be overridden as necessary. This will make creating an OptionsField (or, allowing AttributeField to switch between Attributes and Options) easier.

Part of #35770.

  • This PR is a very minor change/addition and does not require testing instructions (if checked you can ignore/remove the next section).

How to test the changes in this Pull Request:

  1. Go to Products > Add New (MVP)
  2. Interact with the Attributes section and verify there are no regressions (there should be no change in functionality or UX with this PR).

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?

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.

@mattsherman mattsherman added focus: variation Issues related to product variations. focus: product Issues related to product or product page. focus: product management Related to product creation and editing. focus: new product ux revamped product management experience focus: Product Management MVP 1.0 labels Dec 15, 2022
@mattsherman mattsherman self-assigned this Dec 15, 2022
@github-actions github-actions bot added focus: react admin package: @woocommerce/components issues related to @woocommerce/components plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Dec 15, 2022
@github-actions
Copy link
Contributor

Test Results Summary

Commit SHA: 126d401

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202611m 12s
E2E Tests187006019315m 51s

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.

@mattsherman mattsherman changed the title [WIP] Refactor AttributeField into sub-components Refactor AttributeField into sub-components Dec 15, 2022
@mattsherman mattsherman marked this pull request as ready for review December 15, 2022 16:23
@mattsherman mattsherman requested a review from a team December 15, 2022 17:54
Copy link
Contributor

@joshuatf joshuatf left a comment

Choose a reason for hiding this comment

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

Love the refactor direction here and this is testing well (or at least as well as trunk) for me.

I left one comment on the "chips" but not absolutely necessary to resolve here since this issue already existed prior to this PR.

On both this branch and trunk I'm having issues whenever I reorder or make changes to an existing attribute. All attributes seem to inherit the modified attribute properties.

Screen Shot 2022-12-15 at 3 36 08 PM

Pre-approving this PR since this issue also exists for me on trunk but it would be great if @louwie17 could give this a quick spin and share any pointers around the above issue if it can be reproduced.

onDragStart,
onDragEnd,
}: ListItemProps ) => {
const isDraggable = onDragEnd && onDragStart;

return (
<div className={ classnames( 'woocommerce-list-item' ) }>
<div className={ classnames( 'woocommerce-list-item', className ) }>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

<div>{ attribute.name }</div>
<div className="woocommerce-attribute-list-item__options">
{ attribute.options.slice( 0, 2 ).map( ( option, index ) => (
<div
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting that these could be updated to the Tag component, but not absolutely necessary in this PR given this was pre-existing.

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 idea. I'll save that for a follow up PR since this one is approved, has no conflicts, and all tests are passing!

@@ -40,6 +55,27 @@ type AttributeForm = {
};

export const AddAttributeModal: React.FC< AddAttributeModalProps > = ( {
title = __( 'Add attributes', 'woocommerce' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the label props. Very flexible.

@mattsherman
Copy link
Contributor Author

I'm having issues whenever I reorder or make changes to an existing attribute. All attributes seem to inherit the modified attribute properties.

@nathanss found this one a few days ago and created an issue for it! #35901

@mattsherman mattsherman merged commit c94a5c6 into trunk Dec 16, 2022
@mattsherman mattsherman deleted the update/refactor-attribute-field branch December 16, 2022 02:49
@github-actions github-actions bot added this to the 7.4.0 milestone Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: new product ux revamped product management experience focus: product management Related to product creation and editing. focus: product Issues related to product or product page. focus: variation Issues related to product variations. 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.

2 participants