Previously, when I created two HTML templates, opening the second template would automatically close the previous one, ensuring that only one HTML template was visible on the screen at any time. However, with the latest update to Google Sheets, no matter how many HTML templates I create, all of them remain visible on the screen. How can I ensure that when a new HTML template is displayed, the previous ones are closed? Below are example codes and screenshots related to my issue.
Image
function showTemplate1() {
var htmlOutput1 = HtmlService.createHtmlOutputFromFile('page1')
.setWidth(400)
.setHeight(300);
SpreadsheetApp.getUi().showModalDialog(htmlOutput1, 'page1');
var htmlOutput2 = HtmlService.createHtmlOutputFromFile('page2')
.setWidth(200)
.setHeight(100);
SpreadsheetApp.getUi().showModalDialog(htmlOutput2, 'page2');
}
page1
<!DOCTYPE html>
<html>
<body>
<h4>This is Page1</h4>
<p>Goodbye World!</p>
</body>
</html>
page2
<!DOCTYPE html>
<html>
<body>
<h4>This is Page2</h4>
<p>Goodbye World!</p>
</body>
</html>
I was creating two HTML templates. When the second HTML template was opened, the first HTML template would automatically close.