From c7df506d02c48675e70f4f8111a9c4ccbedb02ac Mon Sep 17 00:00:00 2001 From: Sibiraj Date: Sat, 29 Jan 2022 20:19:28 +0530 Subject: [PATCH] perf: use trackBy with ngFor loops --- .../src/lib/modules/menu/bubble/bubble.component.html | 4 ++-- .../src/lib/modules/menu/bubble/bubble.component.ts | 4 ++++ .../menu/color-picker/color-picker.component.html | 4 ++-- .../menu/color-picker/color-picker.component.ts | 4 ++++ .../lib/modules/menu/dropdown/dropdown.component.html | 2 +- .../lib/modules/menu/dropdown/dropdown.component.ts | 4 ++++ .../src/lib/modules/menu/menu.component.html | 11 ++++++----- .../ngx-editor/src/lib/modules/menu/menu.component.ts | 4 ++++ 8 files changed, 27 insertions(+), 10 deletions(-) diff --git a/projects/ngx-editor/src/lib/modules/menu/bubble/bubble.component.html b/projects/ngx-editor/src/lib/modules/menu/bubble/bubble.component.html index d875a99e..b25d2d4b 100644 --- a/projects/ngx-editor/src/lib/modules/menu/bubble/bubble.component.html +++ b/projects/ngx-editor/src/lib/modules/menu/bubble/bubble.component.html @@ -1,5 +1,5 @@ - - + +
diff --git a/projects/ngx-editor/src/lib/modules/menu/bubble/bubble.component.ts b/projects/ngx-editor/src/lib/modules/menu/bubble/bubble.component.ts index a5bb6d47..fe6ce4d0 100644 --- a/projects/ngx-editor/src/lib/modules/menu/bubble/bubble.component.ts +++ b/projects/ngx-editor/src/lib/modules/menu/bubble/bubble.component.ts @@ -52,6 +52,10 @@ export class BubbleComponent implements OnInit, OnDestroy { return this.ngxeService.locals.get(name); } + trackByIndex(index: number): number { + return index + } + onClick(e: MouseEvent, commandName: TBItems): void { e.preventDefault(); e.stopPropagation(); diff --git a/projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.html b/projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.html index 1eb97681..74f69a19 100644 --- a/projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.html +++ b/projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.html @@ -3,8 +3,8 @@
-
- diff --git a/projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.ts b/projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.ts index 960933d4..c62513bc 100644 --- a/projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.ts +++ b/projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.ts @@ -91,6 +91,10 @@ export class ColorPickerComponent implements OnInit, OnDestroy { this.hidePopup(); } + trackByIndex(index: number): number { + return index + } + onColorSelect(e: MouseEvent, color: string): void { e.preventDefault(); diff --git a/projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.html b/projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.html index 14f24c83..ed98140e 100644 --- a/projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.html +++ b/projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.html @@ -3,7 +3,7 @@
-
{{getName(item)}}
diff --git a/projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.ts b/projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.ts index 0dd17794..af97e80f 100644 --- a/projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.ts +++ b/projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.ts @@ -57,6 +57,10 @@ export class DropdownComponent implements OnInit, OnDestroy { this.isDropdownOpen = !this.isDropdownOpen; } + trackByIndex(index: number): number { + return index + } + onClick(e: MouseEvent, item: TBHeadingItems): void { e.preventDefault(); diff --git a/projects/ngx-editor/src/lib/modules/menu/menu.component.html b/projects/ngx-editor/src/lib/modules/menu/menu.component.html index bf431bc9..3c1c387f 100644 --- a/projects/ngx-editor/src/lib/modules/menu/menu.component.html +++ b/projects/ngx-editor/src/lib/modules/menu/menu.component.html @@ -1,7 +1,8 @@ -
+
- - + + @@ -16,8 +17,8 @@ - + diff --git a/projects/ngx-editor/src/lib/modules/menu/menu.component.ts b/projects/ngx-editor/src/lib/modules/menu/menu.component.ts index bae94f16..099164bc 100644 --- a/projects/ngx-editor/src/lib/modules/menu/menu.component.ts +++ b/projects/ngx-editor/src/lib/modules/menu/menu.component.ts @@ -91,6 +91,10 @@ export class MenuComponent implements OnInit { return colors; } + trackByIndex(index: number): number { + return index + } + isDropDown(item: ToolbarItem): boolean { if ((item as ToolbarDropdown)?.heading) { return true;