@@ -59,6 +59,9 @@ function SetCode(func) {
5959 let oldFunc = runFunc ;
6060 runFunc = function ( ) {
6161 oldFunc ( ) ;
62+
63+ SetSession ( SessionKeys . EntityIsAlreadyEmbedded , true ) ;
64+
6265 $ ( '#interact-tab' ) . addClass ( 'enableTransition' ) ;
6366 setTimeout ( function ( ) {
6467 $ ( '#interact-tab' ) . addClass ( 'changeColor' ) ;
@@ -69,6 +72,7 @@ function SetCode(func) {
6972 $ ( '#btnRunCode' ) . off ( 'click' ) ;
7073 $ ( '#btnRunCode' ) . click ( function ( ) {
7174 showEmbedContainer ( ) ;
75+ removeIframeIfUrlIsChanged ( ) ;
7276 elementClicked ( '#btnRunCode' ) ;
7377 runFunc ( ) ;
7478 } ) ;
@@ -169,6 +173,21 @@ function showEmbedContainer() {
169173 $ ( activeContainer ) . css ( { "visibility" :"visible" } ) ;
170174}
171175
176+ function removeIframeIfUrlIsChanged ( ) {
177+ const activeContainer = getActiveEmbedContainer ( ) ;
178+ if ( ! activeContainer || ! activeContainer . powerBiEmbed || ! activeContainer . powerBiEmbed . iframe ) {
179+ return ;
180+ }
181+
182+ let existingIframeUrl = removeUidFromUrl ( activeContainer . powerBiEmbed . iframe . src ) ;
183+ let embedUrl = GetSession ( SessionKeys . EmbedUrl ) ;
184+
185+ if ( embedUrl !== existingIframeUrl ) {
186+ // textbox has changed, delete the iframe and avoid the bootstrap.
187+ powerbi . reset ( activeContainer ) ;
188+ }
189+ }
190+
172191function SetAuthoringPageActive ( report ) {
173192 return new Promise ( function ( resolve , reject ) {
174193
@@ -196,3 +215,14 @@ function SetAuthoringPageActive(report) {
196215 } ) ;
197216 } ) ;
198217}
218+
219+ function removeUidFromUrl ( url ) {
220+ const uidRegEx = / u i d = " ? ( [ ^ & ] + ) " ? /
221+ const uidMatch = url . match ( uidRegEx ) ;
222+
223+ if ( uidMatch ) {
224+ return url . replace ( "&" + uidMatch [ 0 ] , "" ) ;
225+ }
226+
227+ return url ;
228+ }
0 commit comments