Skip to content

Commit 4942604

Browse files
committed
fix to coderabbit's qa
1 parent f214178 commit 4942604

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/components/design-library-list/design-library-list-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const DesignLibraryListItem = props => {
6262

6363
const getCardHeight = () => {
6464
const key = props.enableBackground ? 'background' : 'noBackground'
65-
return cardHeight?.[ key ] || ( props.selectedTab === 'pages' ? 413 : 250 )
65+
return cardHeight?.[ key ] ?? ( props.selectedTab === 'pages' ? 413 : 250 )
6666
}
6767

6868
if ( ! shouldRender && ! props.selectedNum ) {

src/components/design-library-list/design-preview.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,17 @@ export const DesignPreview = ( {
8484
useEffect( () => {
8585
const wrapper = wrapperRef.current
8686

87-
if ( ! wrapper ) {
87+
if ( ! wrapper || ! blocks ) {
8888
return
8989
}
9090

91-
const ric = window.requestIdleCallback || window.requestAnimationFrame
91+
const ric = window.requestIdleCallback || ( cb => setTimeout( cb, designIndex * 20 ) )
9292
const sanitizedHTML = safeHTML( blocks )
9393

9494
if ( selectedTab !== 'pages' || designIndex < 9 ) {
9595
// insert HTML for patterns and for the first 9 pages
9696
wrapper.innerHTML = sanitizedHTML
97+
// No need to call setIsLoading(false) here; isLoading is already false at this point.
9798
return
9899
}
99100

@@ -108,7 +109,7 @@ export const DesignPreview = ( {
108109
} )
109110
} )
110111
} )
111-
}, [ blocks ] )
112+
}, [ blocks ] ) // Only depend on blocks; selectedTab and designIndex changes will cause blocks to update
112113

113114
return createPortal( <>
114115
<body

src/components/design-library-list/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const DesignLibraryItem = props => {
101101
id = requestIdleCallback( () => setShouldRender( true ) )
102102
} else {
103103
// fallback
104-
id = setTimeout( () => setShouldRender( true ), 0 )
104+
id = setTimeout( () => setShouldRender( true ), props.designIndex * 20 )
105105
}
106106

107107
return () => {

0 commit comments

Comments
 (0)