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

Build: Fix errors related to WP5.8-beta2 updates and drop IE11 support. #4362

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 33 additions & 29 deletions assets/js/blocks/attribute-filter/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,6 @@ const AttributeFilterBlock = ( {
queryState.attributes,
] );

// Track checked STATE changes - if state changes, update the query.
useEffect( () => {
if ( ! blockAttributes.showFilterButton ) {
onSubmit( checked );
}
}, [ blockAttributes.showFilterButton, checked, onSubmit ] );

const checkedQuery = useMemo( () => {
return productAttributesQuery
.filter(
( { attribute } ) => attribute === attributeObject.taxonomy
)
.flatMap( ( { slug } ) => slug );
}, [ productAttributesQuery, attributeObject.taxonomy ] );

const currentCheckedQuery = useShallowEqual( checkedQuery );
const previousCheckedQuery = usePrevious( currentCheckedQuery );
// Track ATTRIBUTES QUERY changes so the block reflects current filters.
useEffect( () => {
if (
! isShallowEqual( previousCheckedQuery, currentCheckedQuery ) && // checked query changed
! isShallowEqual( checked, currentCheckedQuery ) // checked query doesn't match the UI
) {
setChecked( currentCheckedQuery );
}
}, [ checked, currentCheckedQuery, previousCheckedQuery ] );

/**
* Returns an array of term objects that have been chosen via the checkboxes.
*/
Expand Down Expand Up @@ -227,6 +200,33 @@ const AttributeFilterBlock = ( {
]
);

// Track checked STATE changes - if state changes, update the query.
useEffect( () => {
if ( ! blockAttributes.showFilterButton ) {
onSubmit( checked );
}
}, [ blockAttributes.showFilterButton, checked, onSubmit ] );

const checkedQuery = useMemo( () => {
return productAttributesQuery
.filter(
( { attribute } ) => attribute === attributeObject.taxonomy
)
.flatMap( ( { slug } ) => slug );
}, [ productAttributesQuery, attributeObject.taxonomy ] );

const currentCheckedQuery = useShallowEqual( checkedQuery );
const previousCheckedQuery = usePrevious( currentCheckedQuery );
// Track ATTRIBUTES QUERY changes so the block reflects current filters.
useEffect( () => {
if (
! isShallowEqual( previousCheckedQuery, currentCheckedQuery ) && // checked query changed
! isShallowEqual( checked, currentCheckedQuery ) // checked query doesn't match the UI
) {
setChecked( currentCheckedQuery );
}
}, [ checked, currentCheckedQuery, previousCheckedQuery ] );

const multiple =
blockAttributes.displayStyle !== 'dropdown' ||
blockAttributes.queryType === 'or';
Expand Down Expand Up @@ -305,9 +305,13 @@ const AttributeFilterBlock = ( {
if ( ! previouslyChecked ) {
newChecked.push( checkedValue );
newChecked.sort();
announceFilterChange( { filterAdded: checkedValue } );
announceFilterChange( {
filterAdded: checkedValue,
} );
} else {
announceFilterChange( { filterRemoved: checkedValue } );
announceFilterChange( {
filterRemoved: checkedValue,
} );
}
}

Expand Down
16 changes: 5 additions & 11 deletions bin/webpack-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const getFrontConfig = ( options = {} ) => {
options: {
presets: [
[
'@babel/preset-env',
'@wordpress/babel-preset-default',
{
modules: false,
targets: {
Expand All @@ -328,9 +328,6 @@ const getFrontConfig = ( options = {} ) => {
require.resolve(
'@babel/plugin-transform-react-jsx'
),
require.resolve(
'@babel/plugin-proposal-async-generator-functions'
),
require.resolve(
'@babel/plugin-transform-runtime'
),
Expand Down Expand Up @@ -403,7 +400,7 @@ const getPaymentsConfig = ( options = {} ) => {
options: {
presets: [
[
'@babel/preset-env',
'@wordpress/babel-preset-default',
{
modules: false,
targets: {
Expand All @@ -421,9 +418,6 @@ const getPaymentsConfig = ( options = {} ) => {
require.resolve(
'@babel/plugin-transform-react-jsx'
),
require.resolve(
'@babel/plugin-proposal-async-generator-functions'
),
require.resolve(
'@babel/plugin-transform-runtime'
),
Expand Down Expand Up @@ -509,9 +503,9 @@ const getExtensionsConfig = ( options = {} ) => {
require.resolve(
'@babel/plugin-transform-react-jsx'
),
require.resolve(
'@babel/plugin-proposal-async-generator-functions'
),
// require.resolve(
// '@babel/plugin-proposal-async-generator-functions'
// ),
require.resolve(
'@babel/plugin-transform-runtime'
),
Expand Down
108 changes: 88 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.14.5",
"@babel/preset-typescript": "7.14.5",
"@babel/plugin-transform-runtime": "7.14.5",
"@octokit/graphql": "4.6.4",
"@storybook/addon-a11y": "6.1.18",
"@storybook/addon-actions": "6.1.18",
Expand Down Expand Up @@ -106,10 +107,10 @@
"@woocommerce/eslint-plugin": "1.1.0",
"@woocommerce/woocommerce-rest-api": "1.0.1",
"@wordpress/api-fetch": "3.23.1",
"@wordpress/babel-preset-default": "4.18.1",
"@wordpress/babel-preset-default": "6.2.0",
"@wordpress/base-styles": "3.2.0",
"@wordpress/blocks": "6.22.0",
"@wordpress/browserslist-config": "2.7.0",
"@wordpress/browserslist-config": "4.0.1",
"@wordpress/components": "11.1.1",
"@wordpress/data-controls": "1.20.8",
"@wordpress/dependency-extraction-webpack-plugin": "2.8.0",
Expand All @@ -123,11 +124,7 @@
"@wordpress/scripts": "13.0.1",
"autoprefixer": "10.2.6",
"axios": "0.21.1",
"babel-plugin-transform-async-generator-functions": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-plugin-transform-react-jsx": "6.24.1",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"babel-plugin-transform-runtime": "6.23.0",
"chalk": "4.1.1",
"circular-dependency-plugin": "5.2.2",
"commander": "6.2.1",
Expand Down