Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: v5
Choose a base branch
from

Conversation

capi1O
Copy link
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.

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