feat: sticky ancestor tabs#2424
Open
the-nelsonator wants to merge 2 commits into
Open
Conversation
Contributor
Author
Not related to these changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2368
Summary
Adds an optional sticky ancestor tab section to tabs panels. When enabled, the ancestor chain (parent → grandparent → …) of the active tab is pinned to the top of the panel as you scroll, so you never lose track of where you are in a large tree. Clicking a sticky row activates that ancestor (and scrolls to it).
Controlled by settings
Tabs > Tabs tree > Sticky ancestor tabs(off by default) andSticky ancestor tabs depth limit(default 3).Demo: https://pixeldrain.com/u/pcLTdKNC
Behaviour
1–5/none) so deep trees don't fill the viewport.Implementation notes
Compute —
Tabs.calcStickyTabs(panel)(src/services/tabs.fg.scroll.ts):Tabs.byId[Tabs.activeId]; bails unless the active tab is in this panel and not pinned.parentIdchain (root → active).idx*rowH - scrollTop < stackBottom, thenstackBottom += rowH. Each pinned row pushes the cutoff down by one row height (it hides the tab beneath it). Short-circuits at the first fully-visible ancestor since rows are monotonically ordered.panel.reactive.stickyTabIdsonly when it changes.Recompute triggers:
scrolllistener on the panel's scroll element.onTabActivated(tabs.fg.handlers.ts) for the new panel and the panel the active tab left (Tabs.activeIdisn't Vue-reactive).watchonvisibleTabIds+ the feature setting inpanel.tabs.vue, plus an initial compute on mount.Rendering:
sticky-tabs.vueoverlay renders the realtab.vuecomponent with a new:stickyprop, one per id.tab.vuegainssticky?: boolean: omits theid="tab<id>"attribute (no duplicate DOM ids), adds a-stickyclass, and — crucially — does not write the shared element refs (titleEl/favImgEl/favSvgUseEl/flashFxEl) onto the tab object, which would hijack the real row's imperative favicon/title/flash updates. The favicon is instead rendered into the clone's own elements via the newTabs.renderFaviconInto(tab, imgEl, svgUseEl)(extracted fromrenderFavicon);onErrorfalls back locally too.src/styles/sidebar/sticky-tabs.styl: a zero-heightposition: sticky; top: 0anchor inside the scroll viewport (same mechanism as the existing new-tab bar), so it takes no flow space (no layout shift) and aligns automatically. Solid backdrop + a separator shadow under the lowest row.Files changed
types/settings.ts,defaults/settings.ts,page.setup/components/settings.tabs.vue,_locales/dict.setup-page.tstypes/sidebar.ts,defaults/panels.tsservices/tabs.fg.scroll.ts(calcStickyTabs),services/tabs.fg.ts(renderFaviconInto),services/tabs.fg.handlers.ts(recompute on activation)sidebar/components/sticky-tabs.vue(new),sidebar/components/tab.vue(stickyprop),sidebar/components/panel.tabs.vue(overlay + triggers)styles/sidebar/sticky-tabs.styl(new) + import instyles/sidebar/sidebar.styl