feat(UI): automatic scroll on selected tab

This commit is contained in:
Fabio Di Stasio 2021-08-05 13:44:48 +02:00
parent 065de3a0a2
commit e834fe31ac
1 changed files with 16 additions and 1 deletions

View File

@ -18,6 +18,7 @@
<li
v-for="(tab, i) of draggableTabs"
:key="i"
:ref="selectedTab === tab.uid ? 'tab-selected' : ''"
class="tab-item tab-draggable"
draggable="true"
:class="{'active': selectedTab === tab.uid}"
@ -361,7 +362,7 @@ export default {
return false;
},
selectedTab () {
return this.workspace.selectedTab;
return this.workspace.selectedTab || null;
},
queryTabs () {
return this.workspace.tabs.filter(tab => tab.type === 'query');
@ -374,6 +375,20 @@ export default {
return false;
}
},
watch: {
selectedTab (newVal, oldVal) {
if (newVal !== oldVal) {
setTimeout(() => {
const element = this.$refs['tab-selected'] ? this.$refs['tab-selected'][0] : null;
if (element) {
element.setAttribute('tabindex', '-1');
element.focus();
element.removeAttribute('tabindex');
}
}, 50);
}
}
},
async created () {
await this.addWorkspace(this.connection.uid);
const isInitiated = await Connection.checkConnection(this.connection.uid);