[Product Block Editor]: exclude the current product from the suggested ones to use in the Linked Product tab (#43662)
* exclude the current product from the suggested list * changelog
This commit is contained in:
parent
dc0fd26917
commit
ea3504b372
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: add
|
||||
|
||||
[Product Block Editor]: exclude the current product from the suggested ones to use in the Linked Product tab
|
|
@ -98,7 +98,12 @@ export function LinkedProductListBlockEdit( {
|
|||
|
||||
const filter = useCallback(
|
||||
( search = '' ) => {
|
||||
return searchProductsDispatcher( linkedProductIds ?? [], search );
|
||||
// Exclude the current product and any already linked products.
|
||||
const exclude = [ productId ];
|
||||
if ( linkedProductIds ) {
|
||||
exclude.push( ...linkedProductIds );
|
||||
}
|
||||
return searchProductsDispatcher( exclude, search );
|
||||
},
|
||||
[ linkedProductIds ]
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue