Skip to content

Fix v5 separate new tab position for tabs opened with new tab button#2008

Closed
capi1O wants to merge 6 commits intombnuqw:v5from
capi1O:fix-v5-separate-new-tab-position-for-tabs-opened-with-New-Tab-button
Closed

Fix v5 separate new tab position for tabs opened with new tab button#2008
capi1O wants to merge 6 commits intombnuqw:v5from
capi1O:fix-v5-separate-new-tab-position-for-tabs-opened-with-New-Tab-button

Conversation

@capi1O
Copy link
Copy Markdown
Contributor

@capi1O capi1O commented Feb 13, 2025

This adds a dedicated setting for new tab position when Sidebery New Tab (+) button is clicked as requested in issue #1096

How it works

New Tab button calls function createTabInPanel. AFAIK this function is not called when native tab creation (for instance Ctrl+T) is used.

createTabInPanel calls getIndexForNewTab and getParentForNewTab (also later getPanelForNewTab might be called). For these functions I added the flag fromNewTabButton in their object argument, so they have a way to determine how the tab was created (natively or from the New Tab button).
By checking the flag they can choose the correct setting (moveNewTab or moveNewTabButton) from which the logic of tab placement is based.

Remarks

  1. Please check translations in dict.setup-page.ts for key settings.move_new_tab_button since I used Google Translate.
  2. This new setting moveNewTabButton reuses the possible values for setting moveNewTab (new tab position (general rule), that is ['start', 'end', 'before', 'after', 'first_child', 'last_child', 'none']. If dedicated options are needed, please ask.
  3. In order to DRY I used functions that I named getIndexForNewTabOtherCases, getParentForNewTabOtherCases and getPanelForNewTabOtherCases because the logic is the same for settings moveNewTab and moveNewTabButton. Let me know if I should name them otherwise but I could not think of something else. last commit 5d3fdf3 avoids this.
  4. The penultimate commit e6704d5 is not required but it enforces consistency, so the flag fromNewTabButton is passed to the 3 functions getIndexForNewTab, getParentForNewTab and getPanelForNewTab in the same way, that is in a an object.
  5. Last but not least I did not test all the configurations for the different settings of new tab position since I did not understand them all. I tested all of the 7 options and when needed with/without active tab being pinned, for both moveNewTab and moveNewTabButton.

@mbnuqw mbnuqw closed this in 8d88446 Oct 4, 2025
danielbodnar pushed a commit to bodnar-dev/sidebery that referenced this pull request Oct 18, 2025
Supersedes mbnuqw#2008. Changes:
Updated setting's name to clarify what New Tab button is meant (native or sidebery).
Use the setting only when interacting with the Sidebery new tab button.
Refactoring.

(resolves mbnuqw#2008)
(resolves mbnuqw#1096)

Co-authored-by: capi1O <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant