Fix variations initial load (#43583)
* Retrieve new variations if not already generating * Add changelog * Fix lint error
This commit is contained in:
parent
4b5c6982e4
commit
ec85c4bd4a
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: fix
|
||||
|
||||
Fix issue when generating variations for the first time in the new editor.
|
|
@ -21,7 +21,6 @@ import { ProductEditorBlockEditProps } from '../../../types';
|
|||
|
||||
export function SectionBlockEdit( {
|
||||
attributes,
|
||||
clientId,
|
||||
}: ProductEditorBlockEditProps< SectionBlockAttributes > ) {
|
||||
const { description, title, blockGap } = attributes;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue