File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,22 @@ const isAdvancedQueryLoop = ( props ) => {
5252 * @return {Element } BlockEdit instance
5353 */
5454const withAdvancedQueryControls = ( BlockEdit ) => ( props ) => {
55- const { currentPostId, currentPostType } = useSelect ( ( select ) => {
56- const editor = select ( editorStore ) ;
57- return {
58- currentPostId : editor . getCurrentPostId ( ) ,
59- currentPostType : editor . getCurrentPostType ( ) ,
60- } ;
61- } ) ;
55+ const { currentPostId, currentPostType } = useSelect (
56+ ( select ) => {
57+ if ( ! isAdvancedQueryLoop ( props ) ) {
58+ return {
59+ currentPostId : undefined ,
60+ currentPostType : undefined ,
61+ } ;
62+ }
63+ const editor = select ( editorStore ) ;
64+ return {
65+ currentPostId : editor . getCurrentPostId ( ) ,
66+ currentPostType : editor . getCurrentPostType ( ) ,
67+ } ;
68+ } ,
69+ [ props ?. attributes ?. namespace ]
70+ ) ;
6271
6372 // If the is the correct variation, add the custom controls.
6473 if ( isAdvancedQueryLoop ( props ) ) {
You can’t perform that action at this time.
0 commit comments