Fix 'Show Sorting Dropdown' attribute ignored in All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/2019)

* Fix 'Show Sorting Dropdown' attribute ignored in All Products block

* Update snapshot
This commit is contained in:
Albert Juhé Lluveras 2020-03-25 12:19:24 +01:00 committed by GitHub
parent c7e20c29d9
commit b67e5a5f10
2 changed files with 8 additions and 5 deletions

View File

@ -52,11 +52,14 @@ const blockSettings = {
* @param {Object} attributes Attributes to save.
*/
save( { attributes } ) {
const dataAttributes = {};
Object.keys( attributes )
.sort()
.forEach( ( key ) => {
dataAttributes[ key ] = attributes[ key ];
} );
const data = {
'data-attributes': JSON.stringify(
attributes,
Object.keys( attributes ).sort()
),
'data-attributes': JSON.stringify( dataAttributes ),
};
return (
<div

View File

@ -2,6 +2,6 @@
exports[`All Products can be created 1`] = `
"<!-- wp:woocommerce/all-products {\\"columns\\":3,\\"rows\\":3,\\"alignButtons\\":false,\\"contentVisibility\\":{\\"orderBy\\":true},\\"orderby\\":\\"date\\",\\"layoutConfig\\":[[\\"woocommerce/product-image\\"],[\\"woocommerce/product-title\\"],[\\"woocommerce/product-price\\"],[\\"woocommerce/product-rating\\"],[\\"woocommerce/product-button\\"]]} -->
<div class=\\"wp-block-woocommerce-all-products wc-block-all-products\\" data-attributes=\\"{&quot;alignButtons&quot;:false,&quot;columns&quot;:3,&quot;contentVisibility&quot;:{},&quot;isPreview&quot;:false,&quot;layoutConfig&quot;:[[&quot;woocommerce/product-image&quot;],[&quot;woocommerce/product-title&quot;],[&quot;woocommerce/product-price&quot;],[&quot;woocommerce/product-rating&quot;],[&quot;woocommerce/product-button&quot;]],&quot;orderby&quot;:&quot;date&quot;,&quot;rows&quot;:3}\\"></div>
<div class=\\"wp-block-woocommerce-all-products wc-block-all-products\\" data-attributes=\\"{&quot;alignButtons&quot;:false,&quot;columns&quot;:3,&quot;contentVisibility&quot;:{&quot;orderBy&quot;:true},&quot;isPreview&quot;:false,&quot;layoutConfig&quot;:[[&quot;woocommerce/product-image&quot;],[&quot;woocommerce/product-title&quot;],[&quot;woocommerce/product-price&quot;],[&quot;woocommerce/product-rating&quot;],[&quot;woocommerce/product-button&quot;]],&quot;orderby&quot;:&quot;date&quot;,&quot;rows&quot;:3}\\"></div>
<!-- /wp:woocommerce/all-products -->"
`;