Fix variations initial load (#43583)

* Retrieve new variations if not already generating

* Add changelog

* Fix lint error
This commit is contained in:
louwie17 2024-01-12 17:13:22 -04:00 committed by GitHub
parent 4b5c6982e4
commit ec85c4bd4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Fix issue when generating variations for the first time in the new editor.

View File

@ -21,7 +21,6 @@ import { ProductEditorBlockEditProps } from '../../../types';
export function SectionBlockEdit( {
attributes,
clientId,
}: ProductEditorBlockEditProps< SectionBlockAttributes > ) {
const { description, title, blockGap } = attributes;

View File

@ -70,10 +70,6 @@ export function useVariations( { productId }: UseVariationsProps ) {
}
}
useEffect( () => {
getCurrentVariationsPage( { product_id: productId } );
}, [ productId ] );
function onPageChange( page: number ) {
getCurrentVariationsPage( {
product_id: productId,
@ -458,6 +454,12 @@ export function useVariations( { productId }: UseVariationsProps ) {
const wasGenerating = useRef( false );
useEffect( () => {
if ( ! isGenerating ) {
getCurrentVariationsPage( { product_id: productId } );
}
}, [ productId, isGenerating ] );
useEffect( () => {
if ( isGenerating ) {
clearFilters();