Currently, my task pane is shown using the Ribbon ShowTaskPane command.
<Action xsi:type="ShowTaskpane">
How do I hide the task pane in Javascript?
Cheers!
At present, the Office add-in doesn't support to hide the task pane via Office JavaScript API.
You may submit the feedback from here if you require this feature.