File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed
src/components/design-library-list Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ( ) => {
You can’t perform that action at this time.
0 commit comments