Skip to content

Commit

Permalink
Sort tabs after registering a tab
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <[email protected]>
  • Loading branch information
raimund-schluessler committed Mar 16, 2023
1 parent 95d5704 commit 9349538
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/components/NcAppSidebar/NcAppSidebarTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@keydown.33.exact.prevent="focusFirstTab"
@keydown.34.exact.prevent="focusLastTab">
<ul>
<li v-for="tab in sortedTabs" :key="tab.id" class="app-sidebar-tabs__tab">
<li v-for="tab in tabs" :key="tab.id" class="app-sidebar-tabs__tab">
<a :id="tab.id"
:aria-controls="`tab-${tab.id}`"
:aria-selected="activeTab === tab.id"
Expand Down Expand Up @@ -117,16 +117,6 @@ export default {
currentTabIndex() {
return this.tabs.findIndex(tab => tab.id === this.activeTab)
},
sortedTabs() {
return [...this.tabs].sort((a, b) => {
const orderA = a.order || 0
const orderB = b.order || 0
if (orderA === orderB) {
return OC.Util.naturalSortCompare(a.name, b.name)
}
return orderA - orderB
})
},
},

watch: {
Expand Down Expand Up @@ -228,6 +218,14 @@ export default {
*/
registerTab(tab) {
this.tabs.push(tab)
this.tabs.sort((a, b) => {
const orderA = a.order || 0
const orderB = b.order || 0
if (orderA === orderB) {
return OC.Util.naturalSortCompare(a.name, b.name)
}
return orderA - orderB
})
this.updateActive()
},

Expand Down

0 comments on commit 9349538

Please sign in to comment.