I am embedding the quicksight Q bar in the angular application. When I navigate from the quicksight page to another page and return to the quicksight page, the previous iframe is still there and I see two Q bars, one the old one and another the new one. How to destroy the old session
Here is my angular code
async embedQSearchBar(embedUrl: string): Promise<void> {
try {
const {createEmbeddingContext} = QuickSightEmbedding;
const embeddingContext = await createEmbeddingContext({
onChange: (changeEvent, metadata) => {
console.log('Context received a change', changeEvent, metadata);
},
});
console.log('>>>>>. Embedding context created:', embeddingContext);
const containerDiv = document.getElementById('pymntSearch');
const frameOptions = {
url: embedUrl,
container: containerDiv,
height: '500px',
width: '1000px',
onChange: (changeEvent, metadata) => {
console.log('Frame onChange:', changeEvent, metadata);
switch (changeEvent.eventName) {
case 'FRAME_MOUNTED':
console.log('Experience frame is mounted.');
break;
}
},
};
const contentOptions = {
hideTopicName: false,
allowTopicSelection: true,
onMessage: (messageEvent, experienceMetadata) => {
console.log('Content onMessage:', messageEvent, experienceMetadata);
switch (messageEvent.eventName) {
case 'Q_SEARCH_OPENED':
console.log('Q Search content expanded');
break;
case 'CONTENT_LOADED':
console.log('Q Search is loaded.');
break;
}
}
};
console.log('Embedding Q Search Bar with frameOptions:', frameOptions, 'and contentOptions:', contentOptions);
this.embeddedQSearchBarExperience = await embeddingContext.embedQSearchBar(frameOptions, contentOptions);
console.log('Embedded Q Search Bar Experience:', this.embeddedQSearchBarExperience);
} catch (error) {
console.error('Error embedding Q Search Bar:', error);
}
}
Please help to resolve this issue