File tree Expand file tree Collapse file tree
components/Editor/Runners/HtmlRunner Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ const getIframeDocument = () => {
1313} ;
1414
1515const getIframeBody = ( ) => {
16- const iframeDocument = getIframeDocument ( ) ;
17- return iframeDocument . its ( "body" ) . should ( "not.be.null" ) . then ( cy . wrap ) ;
16+ return getIframeDocument ( ) . its ( "body" ) . should ( "not.be.null" ) ;
1817} ;
1918
2019const makeNewFile = ( filename = "new.html" ) => {
@@ -183,6 +182,9 @@ it("allows internal links", () => {
183182
184183 const internalLink = getIframeBody ( ) . find ( "a" ) ;
185184 internalLink . click ( ) ;
186- const content = getIframeBody ( ) . find ( "p" ) ;
187- content . should ( "include.text" , "hello world" ) ;
185+ cy . get ( "editor-wc" )
186+ . shadow ( )
187+ . find ( "iframe[class=htmlrunner-iframe]" )
188+ . its ( "0.contentDocument.body" )
189+ . should ( "contain.text" , "hello world" ) ;
188190} ) ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ function HtmlRunner() {
5959
6060 const dispatch = useDispatch ( ) ;
6161 const output = useRef ( null ) ;
62+ const reloadAfterPreviewChange = useRef ( false ) ;
6263
6364 const isMobile = useMediaQuery ( { query : MOBILE_MEDIA_QUERY } ) ;
6465
@@ -141,6 +142,7 @@ function HtmlRunner() {
141142 } else if ( event . data ?. msg === "Allowed external link" ) {
142143 handleAllowedExternalLink ( event . data . payload . linkTo ) ;
143144 } else {
145+ reloadAfterPreviewChange . current = true ;
144146 handleRegularExternalLink ( event . data . payload . linkTo , setPreviewFile ) ;
145147 }
146148 }
@@ -205,6 +207,13 @@ function HtmlRunner() {
205207 }
206208 } , [ focussedFileIndex , openFiles ] ) ;
207209
210+ useEffect ( ( ) => {
211+ if ( reloadAfterPreviewChange . current ) {
212+ reloadAfterPreviewChange . current = false ;
213+ dispatch ( triggerCodeRun ( ) ) ;
214+ }
215+ } , [ previewFile ] ) ;
216+
208217 useEffect ( ( ) => {
209218 if ( isEmbedded && browserPreview ) {
210219 dispatch ( setPage ( runningFile ) ) ;
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ const useExternalLinkState = (showModal) => {
2222 const handleRegularExternalLink = ( linkTo , setPreviewFile ) => {
2323 setExternalLink ( null ) ;
2424 setPreviewFile ( `${ linkTo } .html` ) ;
25- dispatch ( triggerCodeRun ( ) ) ;
2625 } ;
2726
2827 const handleExternalLinkError = ( ) => {
You can’t perform that action at this time.
0 commit comments