1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

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

View File

@ -18,6 +18,7 @@
<li <li
v-for="(tab, i) of draggableTabs" v-for="(tab, i) of draggableTabs"
:key="i" :key="i"
:ref="selectedTab === tab.uid ? 'tab-selected' : ''"
class="tab-item tab-draggable" class="tab-item tab-draggable"
draggable="true" draggable="true"
:class="{'active': selectedTab === tab.uid}" :class="{'active': selectedTab === tab.uid}"
@ -361,7 +362,7 @@ export default {
return false; return false;
}, },
selectedTab () { selectedTab () {
return this.workspace.selectedTab; return this.workspace.selectedTab || null;
}, },
queryTabs () { queryTabs () {
return this.workspace.tabs.filter(tab => tab.type === 'query'); return this.workspace.tabs.filter(tab => tab.type === 'query');
@ -374,6 +375,20 @@ export default {
return false; 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 () { async created () {
await this.addWorkspace(this.connection.uid); await this.addWorkspace(this.connection.uid);
const isInitiated = await Connection.checkConnection(this.connection.uid); const isInitiated = await Connection.checkConnection(this.connection.uid);