@@ -27,25 +27,34 @@ export class TabClient extends WshClient {
2727 throw new Error ( `Block not found: ${ blockId } ` ) ;
2828 }
2929
30- const additionalProps = layoutModel . getNodeAdditionalProperties ( node ) ;
31- if ( ! additionalProps ?. rect ) {
32- throw new Error ( `Block rect not found for: ${ blockId } ` ) ;
33- }
34-
3530 const displayContainer = layoutModel . displayContainerRef . current ;
3631 if ( ! displayContainer ) {
3732 throw new Error ( "Display container not found" ) ;
3833 }
3934
4035 const containerRect = displayContainer . getBoundingClientRect ( ) ;
41- const blockRect = additionalProps . rect ;
42-
43- const electronRect : Electron . Rectangle = {
44- x : Math . round ( containerRect . x + blockRect . left ) ,
45- y : Math . round ( containerRect . y + blockRect . top ) ,
46- width : Math . round ( blockRect . width ) ,
47- height : Math . round ( blockRect . height ) ,
48- } ;
36+ const additionalProps = layoutModel . getNodeAdditionalProperties ( node ) ;
37+
38+ let electronRect : Electron . Rectangle ;
39+
40+ if ( ! additionalProps ?. rect ) {
41+ // Bug: rect is not set when there is only one block in the layout
42+ // In this case, use the full container rect
43+ electronRect = {
44+ x : Math . round ( containerRect . x ) ,
45+ y : Math . round ( containerRect . y ) ,
46+ width : Math . round ( containerRect . width ) ,
47+ height : Math . round ( containerRect . height ) ,
48+ } ;
49+ } else {
50+ const blockRect = additionalProps . rect ;
51+ electronRect = {
52+ x : Math . round ( containerRect . x + blockRect . left ) ,
53+ y : Math . round ( containerRect . y + blockRect . top ) ,
54+ width : Math . round ( blockRect . width ) ,
55+ height : Math . round ( blockRect . height ) ,
56+ } ;
57+ }
4958
5059 return await getApi ( ) . captureScreenshot ( electronRect ) ;
5160 }
0 commit comments