Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "20.0.0"
"version": "20.0.1"
}
21 changes: 20 additions & 1 deletion libs/common-docs/src/lib/docs-section/docs-section.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ContentSection } from '../models/content-section.model';
import { ChangeDetectorRef, Component, Injector, Input } from '@angular/core';
import { Router, NavigationExtras } from '@angular/router';
import { ActivatedRoute, Router, NavigationExtras } from '@angular/router';

const availableTabsPaths = ['overview', 'api', 'examples'] as const;
type AvailableTabsPathsType = typeof availableTabsPaths[number];
Expand Down Expand Up @@ -36,9 +36,28 @@ export class DocsSectionComponent {

constructor(
private injector: Injector,
private activatedRoute: ActivatedRoute,
private router: Router,
private changeDetection: ChangeDetectorRef
) {
this.activatedRoute.queryParamMap.subscribe((params) => {
this.initActiveTab(params.get('tab')?.toString());
});
}

initActiveTab(activeTab?: string) {
this.resetTabs();
if (!activeTab || !this.checkActiveTab(activeTab)) {
this.overview = true;
this.onSelect('overview');
return;
}

this[activeTab as AvailableTabsPathsType] = true;
}

checkActiveTab(activeTab: string): boolean {
return activeTab === 'overview' || activeTab === 'api' || activeTab === 'examples';
}

onSelect(tabName: string) {
Expand Down
2 changes: 1 addition & 1 deletion libs/doc-pages/tabs/src/lib/demos/dynamic/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface ITab {
export class DemoTabsDynamicComponent {
tabs: ITab[] = [
{ title: 'Dynamic Title 1', content: 'Dynamic content 1', removable: false, disabled: false},
{ title: 'Dynamic Title 2', content: 'Dynamic content 2', removable: false, disabled: false},
{ title: 'Dynamic Title 2', content: 'Dynamic content 2', removable: false, disabled: false, active: true},
{ title: 'Dynamic Title 3', content: 'Dynamic content 3', removable: true, disabled: false}
];

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap-base",
"version": "20.0.0",
"version": "20.0.1",
"license": "MIT",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"schematics": "./schematics/src/collection.json",
Expand Down
2 changes: 1 addition & 1 deletion src/accordion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/accordion",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/alert/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/alert",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/buttons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/buttons",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/carousel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/carousel",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/chronos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/chronos",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/collapse/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/collapse",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/component-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/component-loader",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/datepicker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/datepicker",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/dropdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/dropdown",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/focus-trap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/focus-trap",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/locale/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/locale",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/mini-ngrx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/mini-ngrx",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/modal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/modal",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/pagination/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/pagination",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/popover/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/popover",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/positioning/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/positioning",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/progressbar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/progressbar",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/rating/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/rating",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/root/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap",
"version": "20.0.0",
"version": "20.0.1",
"description": "Angular Bootstrap",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/schematics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "schematics",
"version": "20.0.0",
"version": "20.0.1",
"schematics": "./collection.json",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/schematics/src/utils/current_dependency_versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"NGX_BOOTSTRAP_VERSION": "20.0.0",
"NGX_BOOTSTRAP_VERSION": "20.0.1",
"BOOTSTRAP_VERSION": "^5.2.3"
}
2 changes: 1 addition & 1 deletion src/sortable/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/sortable",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/tabs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/tabs",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
44 changes: 35 additions & 9 deletions src/tabs/tabset.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class TabsetComponent implements OnDestroy {
protected _justified = false;
protected _type = 'tabs';
protected _isKeysAllowed = true;
private defaultActivationScheduled = false;

constructor(
config: TabsetConfig,
Expand All @@ -86,34 +87,59 @@ export class TabsetComponent implements OnDestroy {
// Default behavior - add to end
this.tabs.push(tab);
}

// Set active if it's the first tab and not already active
tab.active = this.tabs.length === 1 && !tab.active;

// Activation logic
// - If the newly added tab is already active, set it active again to leverage
// TabDirective's setter which will deactivate others.
// - Otherwise, schedule a single deferred default-first activation if none active.
if (tab.active) {
tab.active = true;
return;
}

if (!this.defaultActivationScheduled) {
this.defaultActivationScheduled = true;
// Defer default activation to avoid racing template-driven [active] inputs
Promise.resolve().then(() => {
this.defaultActivationScheduled = false;
// Guard in case the tabset changed meanwhile
if (!this.tabs.length) {
return;
}
if (this.tabs.some((t: TabDirective) => !!t.active)) {
return;
}
const firstEnabled = this.tabs.find((t: TabDirective) => !t.disabled);
if (firstEnabled) {
firstEnabled.active = true;
}
});
}
}

private insertTabByOrder(tab: TabDirective): void {
let insertIndex = this.tabs.length; // Default to end

// Find the correct position to insert the ordered tab
for (let i = 0; i < this.tabs.length; i++) {
const existingTab = this.tabs[i];

// If the existing tab has an order and the new tab's order is less than it
if (existingTab.tabOrder !== undefined &&
tab.tabOrder !== undefined &&
if (existingTab.tabOrder !== undefined &&
tab.tabOrder !== undefined &&
tab.tabOrder < existingTab.tabOrder) {
insertIndex = i;
break;
}

// If we reach an unordered tab, we want to insert before it
// (ordered tabs should come before unordered tabs)
if (existingTab.tabOrder === undefined) {
insertIndex = i;
break;
}
}

// Insert at the found position
this.tabs.splice(insertIndex, 0, tab);
}
Expand Down
5 changes: 4 additions & 1 deletion src/tabs/testing/tabset.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ describe('Component: Tabs', () => {
fixture.detectChanges();
});

it('should select first tab as active by default', () => {
it('should select first tab as active by default', async () => {
// Default activation is deferred to a microtask; wait for it before asserting
await fixture.whenStable();
fixture.detectChanges();
expectActiveTabs(element, [true, false, false, false]);
});

Expand Down
2 changes: 1 addition & 1 deletion src/timepicker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/timepicker",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/tooltip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/tooltip",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/typeahead/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/typeahead",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion src/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap/utils",
"version": "20.0.0",
"version": "20.0.1",
"author": "Dmitriy Shekhovtsov <[email protected]>",
"license": "MIT"
}
Loading