Calling sidebarAction.close gives error

(Olivier De Broqueville) #1

I have a context menu which calls a processSearch function when one of its items is selected:


Inside the processSearch function, I’ve got the following code:

        if (isOpen) browser.sidebarAction.close();
        if (logToConsole) console.error(err);

I don’t understand why I’m getting the following error message because processSearch function is a user input handler:

Error: sidebarAction.close may only be called from a user input handler

Could this be a bug?


(Martin Giger) #2

The problem is that you check if the sidebar is open. You should just call close unconditionally from the handler directly and not defer it with a promise.

1 Like