Closing Current Tab or Window using JS?

Currently retool does not allow using window.open or window.close method for closing the current tab.

What we are trying to achieve is this:

We click a button, a number of queries are executed and a notification is shown, after an interval we would like to close the current browser tab.

Is there any way to achieve this? I tried with:

utils.openUrl("https://,", { newTab: false, forceReload: true });

But at best it reloads to a dummy tab that we need to close manually

Unfortunately, this does not work as Retool does not allow using window.open, window.close or window.location.href methods :pensive:

Maybe an alternative approach to achieving this could be to use a URL redirect to a blank page that automatically closes itself after a certain amount of time

I already tried both these ChatGPT suggestions :pensive:

After a while even that became repetitive with no solution.

utils.openUrl("https://,", { newTab: false, forceReload: true }); returns a promise but window methods & setTimout doesn't seem to work in Promise.then or Promise.finally either.

Hi @Ammaraly I'm not aware of any solutions for this behavior :disappointed: but I will submit a feature request!

3 Likes

Hi @Tess, thanks for your response. I was hoping someone from Retool Team would notice this and add a feature request :slight_smile:

It would be a great help for us as this is a required functionality in our use case ( closing the current tab after showing a success modal).

2 Likes

any updates here @Tess ? thanks! :slight_smile:

Hi @DavidD Unfortunately, this hasn't been picked up yet :disappointed: Will post back here if the team is able to pick this up!