[Product Block Editor]: when adding a new attribute, show selected item right after user clicks on it (#46713)

* render selected value before porpulate terms

* changelog
This commit is contained in:
Damián Suárez 2024-04-18 05:22:16 -04:00 committed by GitHub
parent ea27c1f364
commit 2df389329e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
[Product Block Editor]: when adding a new attribute, show selected item right after user clicks on it

View File

@ -237,6 +237,15 @@ export const NewAttributeModal: React.FC< NewAttributeModalProps > = ( {
value &&
! ( typeof value === 'string' )
) {
const selectedAttribute =
getProductAttributeObject(
value
) as EnhancedProductAttribute;
setValue( 'attributes[' + index + ']', {
...selectedAttribute,
} );
resolveSelect(
EXPERIMENTAL_PRODUCT_ATTRIBUTE_TERMS_STORE_NAME
)
@ -250,10 +259,6 @@ export const NewAttributeModal: React.FC< NewAttributeModalProps > = ( {
attribute_id: value.id,
} )
.then( ( terms ) => {
const selectedAttribute =
getProductAttributeObject(
value
) as EnhancedProductAttribute;
if ( termsAutoSelection === 'all' ) {
selectedAttribute.terms = terms;
} else if ( terms.length > 0 ) {