-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Create attribute within the new product MVP #35100
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
Conversation
| : null; | ||
|
|
||
| return ( | ||
| <SelectControl< Pick< QueryProductAttribute, 'id' | 'name' > > |
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.
This is just indented as I had to add a Fragment around this in order to add the create modal
Test Results SummaryCommit SHA: 9a7f07b
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. |
8d5ce35 to
7420a10
Compare
9f67bfd to
24d1302
Compare
24d1302 to
a27aec1
Compare
02a8b3f to
db5bea2
Compare
joshuatf
left a comment
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.
Very nice work, Lourens! Testing well on my end; left a few minor comments, but nothing blocking and pre-approving this PR.
Not a result of this PR, but I noticed a couple of oddities around styling:
- The modal appears off when editing an existing attribute
- The loading indicator is slightly disorienting and jumpy, making it challenging to click an item while loading occurs. This loading indicator might be better as the select control's icon instead of in the list (cc @jarekmorawski). Though this may already be planned and blocked by the select control icon issue.
| }; | ||
|
|
||
| function isEmptyItem( | ||
| item: HydratedAttributeType | { id: undefined } |
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 this be a partial of HydratedAttributeType or does it need to have a separate { id: undefined }?
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 wanted to have a clear differentiator between when a attribute was set and when it wasn't. Using a Partial of HydratedAttributeType would make that a bit more difficult and we did have to manually check if all the attributes exist on that property to deem it as the HydratedAttributeType in several places.
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 could potentially just try null, let me see if that works well.
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 updated it to using HydratedAttributeType | null so that things are more clear.
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.
Awesome!
| options: | ||
| undefined, | ||
| } | ||
| typeof val === |
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.
It would be great to have this as a util method so we could also test it.
E.g., parseAttribute( val: string | Attribute )
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.
Good suggestion, I did do this as part of the fd8af0d commit (it includes the other changes as well)
| name: attribute.name, | ||
| options: [], | ||
| } ); | ||
| if ( attribute.id === -99 ) { |
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.
To reduce the number of attribute.id === -99 checks, maybe we could create a util method isNewAttribute( attribute ) that handles this check for us.
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.
Done as part of: 2dcbcd5
| index + | ||
| '].terms', | ||
| { isEmptyItem( | ||
| formAttr |
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 know that formAttr was not added in this PR, but this confused me for a minute as I thought it was a "form attribute." Would attribute be a more accurate name? Or is there something special about these that is related to the form?
Definitely. The latest approach is to replace the search icon with a loading indicator, but we'll work on that as part of another issue. |
521b1ac to
fd8af0d
Compare
|
@joshuatf this should be ready for re-review, I addressed all your changes.
This should be fixed now after the rebase as I fixed this as part of the create attribute PR -> #35132 (at-least I can't reproduce it anymore)
As @jarekmorawski mentioned this is blocked by the other issue in flight to allow us to move the loading indicator within the input field. |
joshuatf
left a comment
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.
Thanks for the changes, @louwie17! This is still testing well for me and changes look great.
Left one more comment about using refs instead of dom selectors for a possible follow-up issue. Otherwise, LGTM! 🚢
| getItemProps={ getItemProps } | ||
| > | ||
| { item.name } | ||
| { item.id === -99 ? ( |
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.
This could also use the new isNewAttributeListItem right?
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 catch, not sure how I missed that, fixed here: 9a7f07b
| setTimeout( () => { | ||
| setTimeout( () => { | ||
| const valueInputField: HTMLInputElement | null = | ||
| document.querySelector( |
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 think ideally we could use a ref here instead of dom selectors, but we can save that for a follow-up issue as I know that wasn't really a part of this PR.
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.
Yeah currently the SelectControl component doesn't allow us to pass in a ref, I could definitely add that though as a separate PR
| }; | ||
|
|
||
| function isEmptyItem( | ||
| item: HydratedAttributeType | { id: undefined } |
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.
Awesome!
2dcbcd5 to
9a7f07b
Compare
|
@joshuatf could I get a re-review/approval I just updated the one last spot that needed to use the helper function. |
joshuatf
left a comment
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.
Changes look good! LGTM ![]()


All Submissions:
Changes proposed in this Pull Request:
This allows users to create a new attribute if the name they are searching for doesn't exist within the attribute list.
This is currently dependent on #34999 to be merged, which is why it's pointing at that branch.
Kapture.2022-10-14.at.11.23.36.mp4
Address the creation part in #34331 .
How to test the changes in this Pull Request:
new-product-management-experiencefeature flag enabled (you can do so using the latest version of the Beta tester within the mono repo).localStorage.setItem( 'debug', 'wc-admin:*' );run prior, it should show that aproduct_attribute_add_custom_attributehas been fired.Create "text"option, allowing you to add several new items.UpdateorPublishOther information:
pnpm --filter=<project> run changelog add?FOR PR REVIEWER ONLY: