Merged PR 2025: fix(core-tabs): improve tab cleanup and naming logic

fix(core-tabs): improve tab cleanup and naming logic

Refactor tab management to handle checkout state transitions more reliably:

- Extract helpers (formatCustomerTabNameHelper, checkCartHasItemsHelper,
  getNextTabNameHelper) from checkout component to @isa/core/tabs for reuse
- Fix getNextTabNameHelper to count tabs instead of finding max ID,
  preventing gaps in "Vorgang X" numbering
- Add canDeactivateTabCleanup guard to manage tab context based on cart state:
  * Preserves customer context if either cart (regular or reward) has items
  * Updates tab name with customer/organization name when context preserved
  * Resets tab to clean "Vorgang X" state when both carts empty
  * Handles navigation to global areas (without tab ID) gracefully
- Apply canDeactivateTabCleanup to checkout-summary and reward-order-confirmation routes
- Move tab cleanup logic from component ngOnDestroy to reusable guard
- Add comprehensive unit tests for getNextTabNameHelper

This ensures tabs maintain correct state after order completion, properly
display customer context when carts have items, and reset cleanly when
both carts are empty. The guard approach centralizes cleanup logic and
makes it reusable across checkout flows.

Ref: #5480
This commit is contained in:
Nino Righi
2025-11-13 14:10:43 +00:00
committed by Lorenz Hilpert
parent b89cf57a8d
commit 212203fb04
7 changed files with 336 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import { CheckoutReviewComponent } from './checkout-review/checkout-review.compo
import { CheckoutSummaryComponent } from './checkout-summary/checkout-summary.component';
import { PageCheckoutComponent } from './page-checkout.component';
import { CheckoutReviewDetailsComponent } from './checkout-review/details/checkout-review-details.component';
import { canDeactivateTabCleanup } from '@isa/core/tabs';
const routes: Routes = [
{
@@ -22,10 +23,12 @@ const routes: Routes = [
{
path: 'summary',
component: CheckoutSummaryComponent,
canDeactivate: [canDeactivateTabCleanup],
},
{
path: 'summary/:orderIds',
component: CheckoutSummaryComponent,
canDeactivate: [canDeactivateTabCleanup],
},
{ path: '', pathMatch: 'full', redirectTo: 'review' },
],