Scaffold: Focus code editor when selecting tab

This commit is contained in:
Dan Stillman 2020-12-24 02:46:19 -05:00
parent 2ed4bb1c8f
commit 018f04f369
2 changed files with 14 additions and 2 deletions

View file

@ -428,7 +428,19 @@ var Scaffold = new function() {
yield Zotero.Translators.reinit();
}
});
this.handleTabSelect = function (event) {
// Focus editor when switching to tab
var tab = event.target.selectedItem.id.match(/^tab-(.+)$/)[1];
switch (tab) {
case 'import':
case 'code':
case 'tests':
_editors[tab].focus();
break;
}
};
/*
* add template code
*/

View file

@ -97,7 +97,7 @@
</toolbar>
<hbox flex="1">
<tabbox id="left-tabbox" flex="1" width="300">
<tabs id="tabs">
<tabs id="tabs" onselect="Scaffold.handleTabSelect(event)">
<tab id="tab-metadata" label="&scaffold.tabs.metadata.label;"/>
<tab id="tab-code" label="&scaffold.tabs.code.label;"/>
<tab id="tab-import" label="&scaffold.tabs.import.label;"/>