Skip to content

fix: reset active tab to default when opening a new or different record#56

Open
obinnaelviso wants to merge 2 commits into
tastyigniter:4.xfrom
obinnaelviso:fix/tab-state-persists-across-records
Open

fix: reset active tab to default when opening a new or different record#56
obinnaelviso wants to merge 2 commits into
tastyigniter:4.xfrom
obinnaelviso:fix/tab-state-persists-across-records

Conversation

@obinnaelviso

Copy link
Copy Markdown
Contributor

Problem

The active tab was stored in the session under a key derived solely from the form widget's class name — making it global across all records. Navigating to a non-default tab on any record would cause that same tab to be active when opening a new record or a different record.

Fixes tastyigniter/TastyIgniter#1177

Root cause

SessionMaker::makeSessionKey() returns a constant string (the widget class name). All putSession('activeTab', ...) / getSession('activeTab') calls shared a single session slot regardless of which record was open or whether the form was in create/edit context.

Fix

  • Introduced activeTabSessionKey() which namespaces the key per context and record ID (activeTab.edit.{id})
  • For the create context: never read or write the active tab to session — create forms always start on tab 1
  • For the edit context: tab is remembered per individual record

Behaviour after fix

  • Opening a new create form → always lands on tab 1 ✓
  • Opening a different edit record → always lands on tab 1 ✓
  • Returning to the same edit record → restores the last tab viewed on that record ✓

🤖 Generated with Claude Code

The active tab was stored in the session under a global key (class name
only), so all records sharing the same form widget shared one stored tab.
Navigating to tab 3 on record A would open tab 3 on record B or on any
new create form.

Fix: namespace the session key per context and record ID so each record
gets its own stored tab. For the create context, never read or write the
tab to session — create forms always start on tab 1.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 17, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Form widget tab-state leakage across different records by scoping the stored “active tab” session entry to the form context and record identifier, so navigating tabs on one record no longer affects other records.

Changes:

  • Store the active tab under a context/record-specific session key instead of a single global activeTab slot.
  • Skip persisting/restoring the active tab in the create context so new forms default to tab 1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +313 to +315
if ($this->context !== 'create') {
$this->putSession($this->activeTabSessionKey(), $data['tab']);
}
Comment thread src/Admin/Widgets/Form.php Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

[Bug]: New menu item form opens on Specials tab after editing an existing item's Options tab

3 participants