@fundamental-ngx/platform 0.57.4-rc.0 → 0.57.4-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -82,6 +82,9 @@ class IconTabBarBase {
|
|
|
82
82
|
if (changes.tabs && !changes.tabs.firstChange) {
|
|
83
83
|
this._initTabs();
|
|
84
84
|
this._triggerRecalculationVisibleItems();
|
|
85
|
+
if (this._tabWasRemoved(changes)) {
|
|
86
|
+
this._updateSelectedTab(changes);
|
|
87
|
+
}
|
|
85
88
|
return;
|
|
86
89
|
}
|
|
87
90
|
if (changes.isRtl && !changes.isRtl.firstChange) {
|
|
@@ -110,9 +113,11 @@ class IconTabBarBase {
|
|
|
110
113
|
*/
|
|
111
114
|
_selectItem(selectedItem, event) {
|
|
112
115
|
event?.stopPropagation();
|
|
113
|
-
this.selectedUid = selectedItem
|
|
116
|
+
this.selectedUid = selectedItem?.uId;
|
|
114
117
|
this.selectedUidChange.emit(this.selectedUid);
|
|
115
|
-
selectedItem
|
|
118
|
+
if (selectedItem) {
|
|
119
|
+
selectedItem.badge = false;
|
|
120
|
+
}
|
|
116
121
|
this.selected.emit(selectedItem);
|
|
117
122
|
}
|
|
118
123
|
/** @hidden */
|
|
@@ -322,6 +327,49 @@ class IconTabBarBase {
|
|
|
322
327
|
}
|
|
323
328
|
return activeTab;
|
|
324
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* @hidden
|
|
332
|
+
* Checks if a tab was removed from the list of tabs.
|
|
333
|
+
* @param changes - SimpleChanges
|
|
334
|
+
* @returns { boolean } - Returns true if a tab was removed, false otherwise.
|
|
335
|
+
*/
|
|
336
|
+
_tabWasRemoved(changes) {
|
|
337
|
+
return changes.tabs.currentValue.length < changes.tabs.previousValue.length;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* @hidden
|
|
341
|
+
* Updates the selected tab based on the changes in the tabs.
|
|
342
|
+
* If the removed tab was before the selected tab or is the selected tab, it updates the selected tab.
|
|
343
|
+
* If no previous selected tab can be found, it selects the first one.
|
|
344
|
+
* If the removed tab is after the selected tab, no changes are needed.
|
|
345
|
+
* @param changes - SimpleChanges
|
|
346
|
+
*/
|
|
347
|
+
_updateSelectedTab(changes) {
|
|
348
|
+
const selectedIdNumber = Number(this.selectedUid);
|
|
349
|
+
const removedTabIndex = this._getRemovedTabIndex(changes);
|
|
350
|
+
if (isNaN(selectedIdNumber) || removedTabIndex === -1) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
// If the removed tab was before the selected tab or was the selected tab, we need to update the selection.
|
|
354
|
+
if (removedTabIndex <= selectedIdNumber) {
|
|
355
|
+
const previousSelectedTabId = `${selectedIdNumber - 1}`;
|
|
356
|
+
// Mark the previous tab as selected. If it cannot be found, select the first one.
|
|
357
|
+
const selectedItem = this.tabs.find((tab) => tab.uId === previousSelectedTabId) || this.tabs[0];
|
|
358
|
+
this._selectItem(selectedItem);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* @hidden
|
|
363
|
+
* Gets the index of the removed tab based on the changes in the tabs.
|
|
364
|
+
* @param changes - SimpleChanges
|
|
365
|
+
* @returns { number } - The index of the removed tab, or -1 if not found.
|
|
366
|
+
*/
|
|
367
|
+
_getRemovedTabIndex(changes) {
|
|
368
|
+
return changes.tabs.previousValue.findIndex((tab) => {
|
|
369
|
+
const tabStillExists = changes.tabs.currentValue.some((currentTab) => currentTab.id === tab.id);
|
|
370
|
+
return tabStillExists ? false : true;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
325
373
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: IconTabBarBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
326
374
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.4", type: IconTabBarBase, isStandalone: true, inputs: { tabs: { classPropertyName: "tabs", publicName: "tabs", isSignal: false, isRequired: false, transformFunction: null }, isRtl: { classPropertyName: "isRtl", publicName: "isRtl", isSignal: false, isRequired: false, transformFunction: null }, densityMode: { classPropertyName: "densityMode", publicName: "densityMode", isSignal: false, isRequired: false, transformFunction: null }, selectedUid: { classPropertyName: "selectedUid", publicName: "selectedUid", isSignal: false, isRequired: false, transformFunction: null }, tabHeadingLevel: { classPropertyName: "tabHeadingLevel", publicName: "tabHeadingLevel", isSignal: true, isRequired: false, transformFunction: null }, colorAssociations: { classPropertyName: "colorAssociations", publicName: "colorAssociations", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selected", selectedUidChange: "selectedUidChange" }, viewQueries: [{ propertyName: "overflowDirective", first: true, predicate: OverflowListDirective, descendants: true }, { propertyName: "headerElement", first: true, predicate: ["tablist"], descendants: true, read: ElementRef }], usesOnChanges: true, ngImport: i0 }); }
|
|
327
375
|
}
|