Skip to content

Conversation

@joshuatf
Copy link
Contributor

Submission Review Guidelines:

Changes proposed in this Pull Request:

Shows a comma separated list for selected values when a select control is in read-only mode (menu closed). Note that in order for this behavior to work and to allow the "remove" buttons on the tags to continue to work when the menu is open, we need to keep the menu open when clicking the input or clicking one of the remove buttons. Otherwise, clicking the "remove" button closes the menu and the list reverts to read only mode before the item can be removed.

cc @jarekmorawski if this is the expectation and @louwie17 since you last touched this component's open/close state in case you have any "gotchas" around opening/closing.

Screen Shot 2023-04-28 at 2 24 45 PM

Screen Shot 2023-04-28 at 1 58 54 PM

Closes #37727 .

How to test the changes in this Pull Request:

  1. Navigate to Tools -> WCA Test Helper -> Features and enable the new product blocks editing experience
  2. Navigate to Products -> Add new
  3. Add some categories to your product
  4. Note that the categories are in a comma-separated list when the menu is closed
  5. Note that the categories are in "tag" format when the menu is open
  6. Click on the "x" next to the category tags
  7. Make sure the category is removed and that the menu remains open

@joshuatf joshuatf requested a review from a team April 28, 2023 21:33
@joshuatf joshuatf self-assigned this Apr 28, 2023
@github-actions github-actions bot added the package: @woocommerce/components issues related to @woocommerce/components label Apr 28, 2023
@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

@github-actions
Copy link
Contributor

github-actions bot commented Apr 28, 2023

Test Results Summary

Commit SHA: d26e9d5

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests26700202690m 52s
E2E Tests1870010019718m 17s

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.

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @joshuatf, this seemed to test quite well. I did leave a couple small comments/suggestions within the code.

disabled,
inputProps = {},
suffix = <SuffixIcon icon={ search } />,
suffix = <SuffixIcon icon={ chevronDown } />,
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that it is a chevron it makes me want to click on the suffix in order to open the menu, but at the moment it seems to do nothing when I click on the suffix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to be a regression introduced in #37319.

Updated in b9ea93e

}
);

if ( isReadOnly ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make this not the default? and allow us to have an additional prop that either enables the comma separated list, or more abstract and expose a call back where a component can render the items manually:

selectedItems: ( ...props ) => false | JSX.Element; // if false we render the normal?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mostly mention this, as we use this within Attributes as well, and the comma separated items looks weird when a placeholder is also set:
Screenshot 2023-05-01 at 12 27 12 PM
@jarekmorawski I don't know if your intention is to have this to be the new default for all multi-select dropdowns?

Choose a reason for hiding this comment

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

Yes, although we may want to do another iteration based on user feedback. 👍 No need to show the placeholder text when the field is not focused and the dropdown is closed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this to hide the placeholder when in read only mode. Kept the comma separation for all experimental select controls.

@joshuatf
Copy link
Contributor Author

joshuatf commented May 3, 2023

@louwie17 updated based on your and @jarekmorawski's feedback. This should be ready for re-review.

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

@joshuatf thanks for the updated changes, I did notice a couple more bugs now. This seems to be a trickier one.
In the attributes add modal, the single select seems to hide my selected item once it has been selected. And in the multi-select within the Modal I can't seem to remove the selected items when clicking on the x. (see video)

Kapture.2023-05-04.at.14.27.07.mp4

One last suggestion, do you think you can change the mouse over icon for the suffix as well? to the pointer?

@joshuatf
Copy link
Contributor Author

joshuatf commented May 4, 2023

Thanks for the review again, @louwie17!

Updated one more time and it appears everything is working on my end, but let me know if you see otherwise. I think we have a lot of scope creep in this issue and there are underlying issues with how the SelectTree is currently structured. The duplication in this component and borrowing of classes makes me pretty nervous and I think we need to set some time aside to refactor this at some point.

One last suggestion, do you think you can change the mouse over icon for the suffix as well? to the pointer?

I don't think we should do this because the suffix could be any icon and the current behavior in the select control does not always toggle the menu open or closed.

At this point, this component feels pretty inconsistent (even in trunk). We probably need to sit down with @jarekmorawski at some point and consolidate some of our expectations around UI behavior so we can clean up the logic in these components.

louwie17
louwie17 previously approved these changes May 5, 2023
Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @joshuatf, this is testing very well on my end now as well 🚀

I think we have a lot of scope creep in this issue and there are underlying issues with how the SelectTree is currently structured. The duplication in this component and borrowing of classes makes me pretty nervous and I think we need to set some time aside to refactor this at some point.

Yeah I agree, coming back to refactor and do some cleanup is a great idea! These two components (the select control and the tree select control) have become two of our most complicated components despite the numerous refactors already 😢

I don't think we should do this because the suffix could be any icon and the current behavior in the select control does not always toggle the menu open or closed.

Sounds good!

At this point, this component feels pretty inconsistent (even in trunk). We probably need to sit down with @jarekmorawski at some point and consolidate some of our expectations around UI behavior so we can clean up the logic in these components.

👍 👍

@jarekmorawski
Copy link

At this point, this component feels pretty inconsistent (even in trunk). We probably need to sit down with @jarekmorawski at some point and consolidate some of our expectations around UI behavior so we can clean up the logic in these components.

Happy to do it! I'll make that happen. 👍

@joshuatf
Copy link
Contributor Author

joshuatf commented May 5, 2023

Hey @louwie17, had a failing test that I fixed up in fdb067c - could you give this another ✅ ?

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@louwie17 louwie17 merged commit c4806c3 into trunk May 8, 2023
@louwie17 louwie17 deleted the update/37727 branch May 8, 2023 07:17
@github-actions github-actions bot added this to the 7.8.0 milestone May 8, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Tree Select Control to render selected items as comma separated list

4 participants