Skip to content

Fix #20256 - Restore active preferences tab after page refresh#20303

Open
predictor2718 wants to merge 1 commit into
phpmyadmin:QA_5_2from
predictor2718:fix/20256-preferences-tab-not-remembered
Open

Fix #20256 - Restore active preferences tab after page refresh#20303
predictor2718 wants to merge 1 commit into
phpmyadmin:QA_5_2from
predictor2718:fix/20256-preferences-tab-not-remembered

Conversation

@predictor2718

@predictor2718 predictor2718 commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #20256

What this fixes

On all preferences pages (/preferences/features, /preferences/sql, /preferences/navigation, /preferences/main-panel, etc.) the active sub-tab was not remembered after a page refresh or after clicking Apply — the page always reset to the first tab.

Root cause

This is a regression that affects both 5.2 and 6.0.

Commit 53f5247 ("Merge FormDisplay::getDisplay templates") replaced the old custom ul.tabs jQuery tab system with Bootstrap data-bs-toggle="tab". The old implementation in js/config.js had:

  • setTab() — set location.hash = 'tab_' + tabId and wrote the value into input[name=tab_hash]
  • setupConfigTabs() — wired up tab click handlers
  • window.onhashchange — read location.hash on page load and activated the matching tab

When Bootstrap tabs were introduced, all three were deleted without a replacement, even though the PHP side was never broken: MainPanelController (and all other preferences controllers) still read tab_hash from the POST body and redirect to the same URL with the tab ID as a URL fragment via UserPreferences::getUrlToRedirect().

Fix

Restore the behaviour using Bootstrap's own API in js/src/config.js:

  1. On page load — read window.location.hash and activate the matching tab via bootstrap.Tab.getOrCreateInstance().
  2. On shown.bs.tab — write the tab id back to window.location.hash and to input[name=tab_hash], so the PHP redirect after Apply also lands on the correct tab.
  3. On teardown — remove the shown.bs.tab listener to avoid leaks across AJAX navigation.

Test

Added a Selenium E2E test testActiveTabRestoredAfterRefresh in ServerSettingsTest that:

  1. Navigates to Main panel preferences
  2. Switches to the "Tabs" sub-tab
  3. Reloads the page
  4. Asserts that "Tabs" is still active and "Startup" is not visible

…esh via location.hash

Signed-off-by: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com>
@predictor2718 predictor2718 force-pushed the fix/20256-preferences-tab-not-remembered branch from a9c574f to 2afbd34 Compare April 29, 2026 19:18

@williamdes williamdes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay, I'd argue to send it to 6.0

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.

2 participants