Skip to content

Commit

Permalink
Added: Option to auto expand branch on creating new child tab
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnuqw committed Feb 4, 2023
1 parent 8dbfe02 commit f295c03
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/_locales/dict.setup-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,10 @@ export const setupPageTranslations: Translations = {
de: 'Tabs bei Aktivierung automatisch ausklappen',
zh_CN: '激活时自动展开标签页',
},
'settings.auto_exp_tabs_on_new': {
en: 'Auto expand branch on creating a new child tab',
ru: 'Автоматически разворачивать ветку при создании новой дочерней вкладки',
},
'settings.rm_child_tabs': {
en: 'Close child tabs along with parent',
ru: 'Закрывать дочерние вкладки вместе с родительской',
Expand Down
1 change: 1 addition & 0 deletions src/defaults/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const DEFAULT_SETTINGS: SettingsState = {
autoFoldTabs: false,
autoFoldTabsExcept: 'none',
autoExpandTabs: false,
autoExpandTabsOnNew: false,
rmChildTabs: 'none',
tabsChildCount: true,
tabsLvlDots: true,
Expand Down
5 changes: 5 additions & 0 deletions src/page.setup/components/settings.tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ section(ref="el")
:inactive="!Settings.state.tabsTree"
v-model:value="Settings.state.autoExpandTabs"
@update:value="Settings.saveDebounced(150)")
ToggleField(
label="settings.auto_exp_tabs_on_new"
:inactive="!Settings.state.tabsTree"
v-model:value="Settings.state.autoExpandTabsOnNew"
@update:value="Settings.saveDebounced(150)")
SelectField(
label="settings.rm_child_tabs"
optLabel="settings.rm_child_tabs_"
Expand Down
13 changes: 9 additions & 4 deletions src/services/tabs.fg.handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,15 @@ function onTabCreated(tab: Tab, attached?: boolean): void {
if (parent && parent.panelId === tab.panelId) {
// If parent tab is folded
if (parent.folded && !attached) {
// Trigger flash animation
const rParent = Tabs.reactive.byId[parent.id]
if (rParent) Tabs.triggerFlashAnimation(rParent)
// TODO: or unfold branch (add an option)
// Expand branch
if (Settings.state.autoExpandTabsOnNew) {
Tabs.expTabsBranch(parent.id)
}
// or trigger the flash animation
else {
const rParent = Tabs.reactive.byId[parent.id]
if (rParent) Tabs.triggerFlashAnimation(rParent)
}
}

let insideBranch = false
Expand Down
1 change: 1 addition & 0 deletions src/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface SettingsState {
autoFoldTabs: boolean
autoFoldTabsExcept: (typeof SETTINGS_OPTIONS.autoFoldTabsExcept)[number]
autoExpandTabs: boolean
autoExpandTabsOnNew: boolean
rmChildTabs: (typeof SETTINGS_OPTIONS.rmChildTabs)[number]
tabsChildCount: boolean
tabsLvlDots: boolean
Expand Down

0 comments on commit f295c03

Please sign in to comment.