@@ -51,6 +51,7 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
5151 const [ isLinkCopied , setLinkCopied ] = useState < boolean > ( false ) ;
5252 const [ IBCountdown , setIBCountdown ] = useState < number > ( 10 ) ;
5353 const [ builderView , setBuilderView ] = useState < boolean > ( true ) ;
54+ const [ abortCountdown , setAbortCountdown ] = useState < boolean > ( false ) ;
5455 const [ showPreviewModal , setShowPreviewModal ] = useState < boolean > ( false ) ;
5556 const url = new URL ( getWindowLocation ( ) ) ;
5657 const [ stepIndex , setStepIndex ] = useState (
@@ -118,6 +119,7 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
118119 ...builderOptions ,
119120 [ optionKey ] : optionValue ,
120121 } ) ;
122+ setAbortCountdown ( true ) ;
121123 } ;
122124
123125 const toggleBuilderView = async ( ) => {
@@ -173,7 +175,7 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
173175 if ( IBCountdown > 0 ) {
174176 setTimeout ( ( ) => setIBCountdown ( IBCountdown - 1 ) , 1000 ) ;
175177 }
176- if ( IBCountdown === 0 && builderView ) {
178+ if ( IBCountdown === 0 && builderView && ! abortCountdown ) {
177179 toggleBuilderView ( ) ;
178180 }
179181 } , [ IBCountdown ] ) ;
@@ -330,26 +332,8 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
330332 < div className = { styles . optionsHeader } >
331333 < h2 className = { styles . optionsHeaderText } > Builder Settings</ h2 >
332334 < div className = { styles . optionsHeaderButtonsContainer } >
333- { /* {integration.embedLink && (
334- <button
335- className={styles.previewButton}
336- onClick={() => togglePreviewModal(integration.embedLink)}
337- type="button"
338- id="headerButton"
339- >
340- Preview
341- </button>
342- )} */ }
343- { /* <button
344- className={styles.copyButton}
345- onClick={() => window.open(integration.sourceCodeLink, "_blank")}
346- type="button"
347- id="headerButton"
348- >
349- Source Code
350- </button> */ }
351335 < button className = { styles . hideButton } onClick = { toggleBuilderView } type = "button" >
352- { IBCountdown ? `${ IBCountdown } s` : "" }
336+ { IBCountdown && ! abortCountdown ? `${ IBCountdown } s` : "" }
353337 < svg
354338 width = "20"
355339 height = "21"
@@ -376,15 +360,21 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
376360 { integration . embedLink && (
377361 < button
378362 className = { styles . previewButton2 }
379- onClick = { ( ) => togglePreviewModal ( integration . embedLink ) }
363+ onClick = { ( ) => {
364+ togglePreviewModal ( integration . embedLink ) ;
365+ setAbortCountdown ( true ) ;
366+ } }
380367 type = "button"
381368 >
382369 Preview
383370 </ button >
384371 ) }
385372 < button
386373 className = { styles . copyButton2 }
387- onClick = { ( ) => window . open ( integration . sourceCodeLink , "_blank" ) }
374+ onClick = { ( ) => {
375+ window . open ( integration . sourceCodeLink , "_blank" ) ;
376+ setAbortCountdown ( true ) ;
377+ } }
388378 type = "button"
389379 >
390380 Source Code
@@ -415,7 +405,10 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
415405 { integration . embedLink && (
416406 < button
417407 className = { styles . previewButton }
418- onClick = { ( ) => togglePreviewModal ( integration . embedLink ) }
408+ onClick = { ( ) => {
409+ togglePreviewModal ( integration . embedLink ) ;
410+ setAbortCountdown ( true ) ;
411+ } }
419412 type = "button"
420413 id = "headerButton"
421414 >
@@ -424,7 +417,10 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
424417 ) }
425418 < button
426419 className = { styles . copyButton }
427- onClick = { ( ) => window . open ( integration . sourceCodeLink , "_blank" ) }
420+ onClick = { ( ) => {
421+ window . open ( integration . sourceCodeLink , "_blank" ) ;
422+ setAbortCountdown ( true ) ;
423+ } }
428424 type = "button"
429425 id = "headerButton"
430426 >
0 commit comments