14
14
* limitations under the License.
15
15
*/
16
16
17
- import { Size } from '../geometry' ;
18
17
import './snapshotTab.css' ;
19
18
import './tabbedPane.css' ;
20
19
import * as React from 'react' ;
@@ -23,8 +22,7 @@ import { ActionTraceEvent } from '../../../server/trace/common/traceEvents';
23
22
24
23
export const SnapshotTab : React . FunctionComponent < {
25
24
action : ActionTraceEvent | undefined ,
26
- defaultSnapshotInfo : { viewport : Size , url : string } ,
27
- } > = ( { action, defaultSnapshotInfo } ) => {
25
+ } > = ( { action } ) => {
28
26
const [ measure , ref ] = useMeasure < HTMLDivElement > ( ) ;
29
27
const [ snapshotIndex , setSnapshotIndex ] = React . useState ( 0 ) ;
30
28
@@ -57,7 +55,7 @@ export const SnapshotTab: React.FunctionComponent<{
57
55
} , [ snapshotIndex , snapshots ] ) ;
58
56
59
57
const iframeRef = React . useRef < HTMLIFrameElement > ( null ) ;
60
- const [ snapshotInfo , setSnapshotInfo ] = React . useState ( defaultSnapshotInfo ) ;
58
+ const [ snapshotInfo , setSnapshotInfo ] = React . useState ( { viewport : kDefaultViewport , url : '' } ) ;
61
59
React . useEffect ( ( ) => {
62
60
( async ( ) => {
63
61
if ( snapshotInfoUrl ) {
@@ -66,8 +64,7 @@ export const SnapshotTab: React.FunctionComponent<{
66
64
if ( ! info . error )
67
65
setSnapshotInfo ( info ) ;
68
66
} else {
69
- // Reset to default if snapshotInfoUrl was removed
70
- setSnapshotInfo ( defaultSnapshotInfo ) ;
67
+ setSnapshotInfo ( { viewport : kDefaultViewport , url : '' } ) ;
71
68
}
72
69
if ( ! iframeRef . current )
73
70
return ;
@@ -76,7 +73,7 @@ export const SnapshotTab: React.FunctionComponent<{
76
73
} catch ( e ) {
77
74
}
78
75
} ) ( ) ;
79
- } , [ iframeRef , snapshotUrl , snapshotInfoUrl , pointX , pointY , defaultSnapshotInfo ] ) ;
76
+ } , [ iframeRef , snapshotUrl , snapshotInfoUrl , pointX , pointY ] ) ;
80
77
81
78
const snapshotSize = snapshotInfo . viewport ;
82
79
const scale = Math . min ( measure . width / snapshotSize . width , measure . height / snapshotSize . height , 1 ) ;
@@ -124,3 +121,5 @@ function renderTitle(snapshotTitle: string): string {
124
121
return 'Action' ;
125
122
return snapshotTitle ;
126
123
}
124
+
125
+ const kDefaultViewport = { width : 1280 , height : 720 } ;
0 commit comments