Capturing "close" event of Sidebar

281 views
Skip to first unread message

Guy Gummy

unread,
Sep 29, 2021, 2:13:45 AM9/29/21
to Google Apps Script Community
I have a sheet where opening the sidebar enables the user to chose which cells matching some criteria should have their background color changed, as to highlight corresponding cells, but _only_ when the sidebar is open. That is, all "highlighting" must be reset so that the background color of any changed cell goes back to the default sheet background color.

I can handle it with a custom close button, but of course this bugs the bits out of the UIX designer in me (two close buttons? really?). Having to setup an async poll is far more boilerplate than should be needed for something as simple as... 

Can the GAS team add a callback function for when the "close" event of the sidebar occurs? Like how successhandler is interfaced.

Unless someone's got a practical solution (for instance I was hoping I could traverse the DOM and look for the element closest matching the close button closest to the unique literal set for the sidebar's title text, and just add an event listener but my knowledge isn't sufficient to do this simply enough at this time, if it is indeed possible in the GAS/Sheet universe).

Thanks,
Ashton

Clark Lind

unread,
Sep 30, 2021, 10:23:32 AM9/30/21
to Google Apps Script Community
You are trying to do things that aren't part of the platform. You are working from "within" the sheets environment. If you want to manipulate that environment, then you will have to work at the browser level, otherwise, you will always be confined and "sandboxed" by sheets. Also, can't you run some function before calling close? 

<input type="button" value="Close" onclick="updateColorsOnClose() " />

function updateColorsOnClose() {
/  ...your code.../
google.script.host.close()
}

Guy Gummy

unread,
Oct 2, 2021, 8:26:18 PM10/2/21
to google-apps-sc...@googlegroups.com
Thanks, that's what I was figuring. The problem is the use case would require that the close button be pressed by the user, which there is no guarantee of that. Since that's true, then if someone who uses it and doesn't click that button, then another user comes along who isn't as fluent in the UI, now there's a problem. I still feel that GAS should provide an event listener for the closing of the sidebar, but for now I will work around that.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/3959ea39-fb3a-462d-8d34-e6d1fa955c80n%40googlegroups.com.
Message has been deleted
Message has been deleted

Raj Kumar

unread,
Apr 10, 2023, 10:56:20 AM4/10/23
to Google Apps Script Community
Any workaround for this?
Reply all
Reply to author
Forward
0 new messages