'LoadIndicator SPINNER not working with setSuggestionsAction

I am creating a gmail add on with a TextInput field showing suggestions on when text is typed as per this link. For this I have added setSuggestionsAction which gets triggered whenever text inside TextInput is changed. Inside action function I am calling an API to fetch suggestions related to my input field. Everything is working fine, but I want to show a loader or spinner whenever this action is in progress or when an api is called inside action function. For this I have added setLoadIndicator(CardService.LoadIndicator.SPINNER) with the action but this is not working. It is working with onChange action but not with setSuggestionsAction.

Below is my code for Suggestions Input -

var suggestionsTextInput = CardService.newTextInput()
    .setFieldName("name")
    .setTitle("label")
    .setHint("help_text")
    .setOnChangeAction(CardService.newAction().setFunctionName('handleSuggestionsInputChange').setLoadIndicator(CardService.LoadIndicator.SPINNER))
    .setSuggestionsAction(CardService.newAction().setFunctionName('refreshSuggestions').setLoadIndicator(CardService.LoadIndicator.SPINNER));
section.addWidget(suggestionsTextInput);

And setSuggestionsAction function is as below -

function refreshSuggestions(e) {
    var suggestionList = [];
    var searchVal = e.formInput.caller_id;
    if(searchVal.length>=3) {
        var optionsReference = {
            'method' : 'get'
        };
        var response = UrlFetchApp.fetch(
            "https://APIURL",
            optionsReference
        );
        response = JSON.parse(response);
        if(response.result.length>0) {
            response.result.forEach(items => {
              suggestionList.push(items.first_name+" "+items.last_name); 
            })
        }
        return CardService.newSuggestionsResponseBuilder()
            .setSuggestions(CardService.newSuggestions().addSuggestions(suggestionList))
            .build();
    }
    
}

Can anyone tell how I can add a loader while calling suggestions api? TIA.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source