Reload page when toggling new-product-management-experience (#38348)

* Add callback to reload page when togglint new-product-management-experience

* Add changelog

* Implement reload for product-block-editor and code review suggestions
This commit is contained in:
Nathan Silveira 2023-05-19 14:57:51 -03:00 committed by GitHub
parent ebf0b92960
commit ef0a32ff48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: enhancement
Reload page when toggling new-product-management-experience and product-block-editor

View File

@ -23,6 +23,15 @@ function Features() {
const sortedFeatureNames = Object.keys( features ).sort();
const afterToggleCallback = {
'new-product-management-experience': () => {
window.location.reload();
},
'product-block-editor': () => {
window.location.reload();
},
};
return (
<div id="wc-admin-test-helper-features">
<h2>
@ -43,8 +52,9 @@ function Features() {
<ToggleControl
label={ feature_name }
checked={ features[ feature_name ] }
onChange={ () => {
toggleFeature( feature_name );
onChange={ async () => {
await toggleFeature( feature_name );
afterToggleCallback[ feature_name ]?.();
} }
/>
</li>