Closed gabrielrezk closed 3 years ago
Hi @gabrielrezk, correct, this won't work locally, but will work fine in production. It's possible to make this work locally, but just haven't implemented it since it doesn't seem that critical and it will work fine in production. Do you want to work on this feature? Can point you in the right direction if you're interested.
Thanks for your reply @enuchi.
Right, as it works in production it isn't a big deal. But it'd be nice to have it so I might take a look at it at some point.
Do you have something in mind?
Yep, you'd have to make several changes:
closeDialog()
. Similar to how server-side functions work here, you'd have to call google.script.host.close()
in production, but in development send a window.postMessage that should tell the parent iframe to call the close function.closeDialog()
message then call google.script.host.close()
.It would be very similar to what I've implemented to call server-side functions in local development, but a bit easier because you don't have to listen for a response in the other direction (google.script.host.close()
doesn't return anything). Still quite a bit of work though... 😄
Linking to another issue where this came up: https://github.com/enuchi/React-Google-Apps-Script/issues/60.
There is probably a neat way to do this so other client-side google
functions aside can be used in local development @gabrielrezk. Keep me posted if you look into this.
Great @enuchi! Thanks for your input, I'll keep you posted.
Hello, Is there some nicer way of using google.script.host.close();
in development than hacking like this? :) https://gist.github.com/tanaikech/c1b5fb20342dae623139ca0f48c8c12c
In production you just call google.script.host.close() on the client. If you wanted to get it to work in development you'd have to follow the steps I listed above.
Yes it does work when deployed, just that breaks that great dev flow a little :) the missinghost
and url
does complicate stuff a little... would appreciate a piece of code that would make it a bit more clear so I could take it from there and implement the missing parts.
Hi, I am getting started with this boilerplate, trying to migrate a working sheets add-on. And I think I found a limitation.
In our current add-on we used to call the following function to open a modal:
Ui.showModelessDialog
(https://developers.google.com/apps-script/reference/base/ui#showModelessDialog(Object,String)).Also, to close it, we call the client-side function google.script.host.close. But using the boilerplate I found that the google variable is not accessible.
Is there a way to call such client-side functions? Thanks in advance, and awesome work!
Update: The problem only occurs when running the project locally. This happens because the iframe that loads the project from the development server doesn't have access to this variable.