Product Collection: Make sure all variations are taken into account when choosing collection (#43273)
* Make sure all variations are taken into account when choosing collection * Add changelog
This commit is contained in:
parent
aab950e27a
commit
8d4f1cecec
|
@ -1,7 +1,10 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
|
import { select } from '@wordpress/data';
|
||||||
import {
|
import {
|
||||||
|
// @ts-expect-error Type definition is missing
|
||||||
|
store as blocksStore,
|
||||||
type BlockVariation,
|
type BlockVariation,
|
||||||
registerBlockVariation,
|
registerBlockVariation,
|
||||||
BlockAttributes,
|
BlockAttributes,
|
||||||
|
@ -49,7 +52,15 @@ export const getCollectionByName = ( collectionName?: CollectionName ) => {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return collections.find( ( { name } ) => name === collectionName );
|
// @ts-expect-error Type definitions are missing
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/wordpress__blocks/store/selectors.d.ts
|
||||||
|
const variations = select( blocksStore ).getBlockVariations(
|
||||||
|
blockJson.name
|
||||||
|
);
|
||||||
|
|
||||||
|
// @ts-expect-error Type definitions are missing
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/wordpress__blocks/store/selectors.d.ts
|
||||||
|
return variations.find( ( { name } ) => name === collectionName );
|
||||||
};
|
};
|
||||||
|
|
||||||
export default registerCollections;
|
export default registerCollections;
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: enhancement
|
||||||
|
|
||||||
|
Make sure all variations of Product Collection are taken into account when choosing collection by name
|
Loading…
Reference in New Issue