Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Cancel button for product category block #583

Merged
merged 7 commits into from
Jun 27, 2019
Merged

Conversation

mikejolley
Copy link
Member

I wanted to have a quick go at #172 to see how far I could get. This is mainly for my own learning but hopefully I can get it good enough to merge :)

I will add inline comments for things I'm unsure of.

Screenshots

Edit Post ‹ local wordpress test — WordPress 2019-05-21 14-03-31

How to test the changes in this Pull Request:

  1. Edit a category block
  2. Make some changes
  3. Click cancel. Changes won't persist.
  4. Edit again. Changes didn't persist.
  5. Make more changes. Click done. Changes did persist.

@mikejolley mikejolley requested a review from a team May 21, 2019 13:09
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

This is looking really great @mikejolley! I answered some of your inline questions and added one comment that was blocking me to edit the block right after adding it.

@@ -66,7 +101,7 @@ class ProductByCategoryBlock extends Component {
getProducts() {
if ( ! this.props.attributes.categories.length ) {
// We've removed all selected categories, or no categories have been selected yet.
this.setState( { products: [], loaded: true } );
this.setState( { products: [], loaded: true, isEditing: true } );
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you will need to set changedAttributes to an empty object {} too, otherwise changes are not applied because this check always returns false.

Suggested change
this.setState( { products: [], loaded: true, isEditing: true } );
this.setState( { products: [], loaded: true, isEditing: true, changedAttributes: {} } );

Copy link
Member

@ryelle ryelle left a comment

Choose a reason for hiding this comment

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

I've made a few comments, but this is a good start 👍

I did notice that the Product Category panel in the sidebar isn't working anymore – IMO that should stay working as it does currently (updating the preview as the categories are selected, no cancel button).

assets/js/blocks/product-category/block.js Show resolved Hide resolved
assets/js/blocks/product-category/block.js Outdated Show resolved Hide resolved
assets/js/blocks/product-category/block.js Outdated Show resolved Hide resolved
assets/js/blocks/product-category/block.js Outdated Show resolved Hide resolved
assets/js/blocks/product-category/block.js Outdated Show resolved Hide resolved
assets/js/blocks/product-category/block.js Outdated Show resolved Hide resolved
@mikejolley
Copy link
Member Author

Thanks for the feedback. 🤦‍♂ I didn't even notice that sidebar panel.

@mikejolley mikejolley changed the title [Experiment] Cancel button for blocks Cancel button for product category block May 23, 2019
@mikejolley mikejolley marked this pull request as ready for review May 23, 2019 10:34
@mikejolley mikejolley requested a review from ryelle May 23, 2019 10:35
@ryelle
Copy link
Member

ryelle commented May 23, 2019

I'm still triggering a state where the items can't be selected. If I clear all categories (next to 'X categories selected'), then click done, it resets into the editing state but the categories are un-selectable unless I click done/cancel and back into edit. (screen recording)

It's also a little odd to me that I can trigger the "editing" state by clearing categories from the sidebar, can select new categories there, but then need to click done in the main section to see the preview (screen recording)

I also think a designer should look through this, so I'm ccing @josemarques @jwold

@mikejolley
Copy link
Member Author

Thanks, I think I've tackled that now;

  • Updating sidebar saves right away and overwrites and changes in edit mode
  • Fixed the initial state so attributes can be changed

I do have to fix merge conflicts now however since the server side changes also changed the behaviour.

@mikejolley
Copy link
Member Author

mikejolley commented May 24, 2019

The nothing found view was missing also. Putting it back (8f7e8c0) - that shows some text when no cats are selected, instead of showing all products. This matches how it worked previously before server side rendering was introduced.

Copy link
Member

@ryelle ryelle left a comment

Choose a reason for hiding this comment

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

Looks good from a dev perspective, could still use a designer ✅ though so I'm not marking Ready to Merge yet.

@jwold
Copy link

jwold commented Jun 12, 2019

Just following up that I plan to take a look at this shortly. Thanks!

@mikejolley mikejolley added this to the 2.3 milestone Jun 25, 2019
@jwold
Copy link

jwold commented Jun 25, 2019

Just reviewed the screenshots and looked at the original issue this is based off of. The main thing I was looking at was how the cancel button works, and adding that functionality looks good.

cc @mikejolley

@mikejolley mikejolley merged commit 8f7e8c0 into master Jun 27, 2019
@mikejolley mikejolley deleted the experiment/cancel-button branch June 27, 2019 11:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants