How to catch the admin tab switching event in Magento 2
Since Magento 2 utilizes the standard jQuery UI Tabs Widget, you should catch the tabsactivate event to catch the admin tab switching:

$textarea.closest(‘.ui-tabs-panel’).get(0) is a tab you should handle.
data.newPanel.get(0) is the one that becomes active.
