@@ -21,6 +21,7 @@ import getPageTitleByPageUid from "roamjs-components/queries/getPageTitleByPageU
2121import renderOverlay , {
2222 RoamOverlayProps ,
2323} from "roamjs-components/util/renderOverlay" ;
24+ import createPage from "roamjs-components/writes/createPage" ;
2425import { createBlock } from "roamjs-components/writes" ;
2526import {
2627 insertPageRefAtRange ,
@@ -324,27 +325,28 @@ const AdvancedNodeSearchDialog = ({
324325 if ( contentState !== "results" || ! results . length ) return ;
325326
326327 try {
327- const parentUid =
328- ( await window . roamAlphaAPI . ui . mainWindow . getOpenPageOrBlockUid ( ) ) ||
329- window . roamAlphaAPI . util . dateToPageUid ( new Date ( ) ) ;
330-
331328 const sidebarBlockTitle = `Advanced search results: "${ debouncedSearchTerm || "(empty query)" } "` ;
332329 const sidebarChildren = results . map ( ( result ) => ( {
333330 text : `[[${ result . title } ]]` ,
334331 } ) ) ;
335332
336- const sidebarBlockUid = await createBlock ( {
337- parentUid,
338- order : Number . MAX_VALUE ,
339- node : { text : sidebarBlockTitle , children : sidebarChildren } ,
340- } ) ;
333+ const sidebarPageUid = await createPage ( { title : sidebarBlockTitle } ) ;
334+ await Promise . all (
335+ sidebarChildren . map ( ( node , order ) =>
336+ createBlock ( {
337+ parentUid : sidebarPageUid ,
338+ order,
339+ node,
340+ } ) ,
341+ ) ,
342+ ) ;
341343
342344 await window . roamAlphaAPI . ui . rightSidebar . addWindow ( {
343345 window : {
344346 type : "outline" ,
345347 // @ts -expect-error - block-uid is valid for outline sidebar windows
346348 // eslint-disable-next-line @typescript-eslint/naming-convention
347- "block-uid" : sidebarBlockUid ,
349+ "block-uid" : sidebarPageUid ,
348350 } ,
349351 } ) ;
350352
0 commit comments