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 create attribute term modal #35131

Merged
merged 6 commits into from
Nov 1, 2022
Merged

Conversation

louwie17
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

This allows users to create a new attribute term if the term they are searching for doesn't exist within the attribute term list.
This is currently dependent on #34999 to be merged, which is why it's pointing at that branch.

Kapture.2022-10-17.at.13.25.48.mp4

Address the term creation part in #34331 .

How to test the changes in this Pull Request:

  1. Load this branch, build it, and make sure you have the new-product-management-experience feature flag enabled (you can do so using the latest version of the Beta tester within the mono repo).
  2. Go to Products > Add new (MVP) and fill out some of the initial details like name and price
  3. Scroll down and click Add first attribute in the attributes section
  4. Select one of the attributes
  5. Search for a attribute term that doesn't exist yet
  6. The 'Create "your new attribute term name"' should show as an option
  7. Click that and another modal should show with the create fields.
  8. Fill out all the fields and click Add this should create the attribute term and add it as a selected item within the terms field
  9. With localStorage.setItem( 'debug', 'wc-admin:*' ); run prior, it should show that a product_attribute_term_add and product_attribute_term_add_success event has been fired.
  10. Open the modal again and select cancel this shouldn't do anything.
  11. A user should not be able to click add when the name is removed.

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 successfully run tests with your changes locally?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> run 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.

@louwie17 louwie17 requested a review from a team October 17, 2022 16:29
@github-actions github-actions bot added focus: react admin release: highlight Issues that have a high user impact and need to be discussed/paid attention to. labels Oct 17, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 17, 2022

Test Results Summary

Commit SHA: 38dcbb3

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests23200302350m 57s
E2E Tests186006019214m 59s

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/34331_add_attributes_modal branch from 8d5ce35 to 7420a10 Compare October 18, 2022 20:22
Base automatically changed from add/34331_add_attributes_modal to trunk October 19, 2022 19:28
@louwie17 louwie17 force-pushed the add/34331_create_attribute_term_modal branch from 80e7590 to 32001b9 Compare October 20, 2022 12:15
@github-actions github-actions bot added plugin: woocommerce Issues related to the WooCommerce Core plugin. and removed release: highlight Issues that have a high user impact and need to be discussed/paid attention to. labels Oct 20, 2022
@joelclimbsthings joelclimbsthings requested review from joelclimbsthings and removed request for a team October 27, 2022 18:59
getFilteredItems={ ( allItems, inputValue ) => {
if (
inputValue.length > 0 &&
! allItems.find(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note that this will fail if it returns an item that is falsy in any way, but it looks unlikely to cause any issues 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.

Yeah that should be fine, plus the find method already assume the each item contains a name attribute, so, so the item being return will have to contain a name attribute none the less.

type CreateAttributeTermModalProps = {
initialAttributeTermName: string;
attributeId: number;
onCancel: () => void;
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 wondering if there's a possible use case in which these handlers should be optional?

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 don't think so, but I made them optional just incase, I defaulted them to empty functions in this commit: 2f39f27

<TextControl
label={ __( 'Name', 'woocommerce' ) }
{ ...nameInputProps }
onBlur={ () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the onBlur here fires, it actually closes both the terms modal and the add attribute modal, which I'd guess wouldn't be expected. Should we stop it from bubbling down to the add modal as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm could you maybe share a video of this? Things work as expected for me and the Modal doesn't auto close for me when the onBlur is being fired.

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 job @louwie17 !
Added a few very minor comments, and I also noticed that the fields are not responsive on smaller viewports, which might be worth addressing here.

It's also worth noting that we're definitely going to have some conflicts with the edit attributes PR which includes some semi-foundational changes, so we might want to get that merged before too long.

@louwie17 louwie17 force-pushed the add/34331_create_attribute_term_modal branch from 111c87c to 2f39f27 Compare October 28, 2022 18:44
@louwie17
Copy link
Contributor Author

Great job @louwie17 ! Added a few very minor comments, and I also noticed that the fields are not responsive on smaller viewports, which might be worth addressing here.

Thanks for the feedback @joelclimbsthings I addressed most of your feedback, the only item I couldn't reproduce was the onBlur issue you are encountering, I was curious if you could share a video or something, it seems a bit odd to me that this onBlur would trigger that.
I did also address the smaller viewports issue, nice catch!

It's also worth noting that we're definitely going to have some conflicts with the edit attributes PR which includes some semi-foundational changes, so we might want to get that merged before too long.

Get which one merged first?

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, thanks @louwie17 ! I'm not sure if this behavior is actually much of a problem, but I can see it being annoying to users:

Peek 2022-10-28 12-30

At the end of the animation I'm clicking at the spot I'm circling, and you can see that it's closing both modals, not just the terms modal.

Edit: Either way on merging the PRs. I'm good to resolve the conflicts for this one, but don't want the edit modal PR to get too bogged down with other changes coming down.

@louwie17
Copy link
Contributor Author

Right on, thanks @louwie17 ! I'm not sure if this behavior is actually much of a problem, but I can see it being annoying to users:

At the end of the animation I'm clicking at the spot I'm circling, and you can see that it's closing both modals, not just the terms modal.

Aaaha thanks that video helps a lot, I should have a fix Monday morning sometime, it should be relatively simple to handle.

@louwie17 louwie17 force-pushed the add/34331_create_attribute_term_modal branch from 2f39f27 to 38dcbb3 Compare October 31, 2022 13:07
@louwie17
Copy link
Contributor Author

@joelclimbsthings I fixed the issue in this commit: 38dcbb3
Only the second modal should close now, and afterwards the first modal should still close fine.

Hope you have some time to look at it again.

@louwie17 louwie17 requested a review from a team October 31, 2022 13:09
@joelclimbsthings
Copy link
Contributor

Awesome @louwie17 , works beautifully. 🚢 :shipit:

@louwie17 louwie17 merged commit ff2b06c into trunk Nov 1, 2022
@louwie17 louwie17 deleted the add/34331_create_attribute_term_modal branch November 1, 2022 12:05
@github-actions github-actions bot added this to the 7.2.0 milestone Nov 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 1, 2022

Hi @louwie17, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the release: add testing instructions label

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.

2 participants