Skip to content

Commit

Permalink
feat(edit-content) fix bug scrollHandler #28831
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra committed Jun 26, 2024
1 parent 7248d59 commit f5ecf66
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
[ngClass]="{ 'no-overflow-x-yet': emptyColumns().length }"
class="flex-1 category-list__category-list">
@for (column of categories(); let index = $index; track categories()[index]) {
<!--dynamic columns-->
<div #categoryColumn class="category-list__category-column">
@for (item of column; track item.inode) {
<div
class="flex align-content-center align-items-center category-list__item"
[ngClass]="{ 'category-list__item--selected': item.checked }"
(click)="itemClicked.emit({ index, item })">
<p-checkbox [(ngModel)]="itemsSelected" [value]="item.key" />
<!--dynamic columns-->
<div #categoryColumn class="category-list__category-column">
@for (item of column; track item.inode) {
<div
class="flex align-content-center align-items-center category-list__item"
[ngClass]="{ 'category-list__item--selected': item.checked }"
(click)="itemClicked.emit({ index, item })">
<p-checkbox [(ngModel)]="itemsSelected" [value]="item.key" />

<label
class="flex flex-grow-1 category-list__item-label"
[ngClass]="{ 'cursor-pointer': item.childrenCount > 0 }"
[for]="item.key"
>{{ item.categoryName }}</label
>
<label
class="flex flex-grow-1 category-list__item-label"
[ngClass]="{ 'cursor-pointer': item.childrenCount > 0 }"
[for]="item.key"
>{{ item.categoryName }}</label
>

@if (item.childrenCount > 0) {
<i class="pi pi-chevron-right category-list__item-icon"></i>
@if (item.childrenCount > 0) {
<i class="pi pi-chevron-right category-list__item-icon"></i>
}
</div>
}
</div>
}
</div>
}

<!--Fake empty columns-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,32 @@ export class DotCategoryFieldCategoryListComponent implements AfterViewInit {
}

private scrollHandler() {
const columnsArray = this.categoryColumns.toArray();
if (
columnsArray[MINIMUM_CATEGORY_WITHOUT_SCROLLING] &&
columnsArray[MINIMUM_CATEGORY_WITHOUT_SCROLLING].nativeElement.children.length > 0
) {
columnsArray[columnsArray.length - 1].nativeElement.scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'start'
});
try {
const columnsArray = this.categoryColumns.toArray();

if (columnsArray.length === 0) {
return;
}

if (
columnsArray[MINIMUM_CATEGORY_WITHOUT_SCROLLING - 1] &&
columnsArray[MINIMUM_CATEGORY_WITHOUT_SCROLLING - 1].nativeElement.children.length >
0
) {
columnsArray[columnsArray.length - 1].nativeElement.scrollIntoView({
behavior: 'smooth',
block: 'end',
inline: 'end'
});
} else {
columnsArray[0].nativeElement.scrollIntoView({
behavior: 'smooth',
block: 'nearest',
inline: 'start'
});
}
} catch (error) {
console.error('Error during scrollHandler execution:', error);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@if (store.selectedCategories().length) {
<div class="dot-category-field__categories" data-testId="category-chip-list">
@for (category of store.categoriesValue(); track category.key) {
<p-chip
[pTooltip]="category.value"
[removable]="true"
[label]="category.value"
tooltipPosition="top"
styleClass="p-chip-sm" />
}
</div>
<div class="dot-category-field__categories" data-testId="category-chip-list">
@for (category of store.categoriesValue(); track category.key) {
<p-chip
[pTooltip]="category.value"
[removable]="true"
[label]="category.value"
tooltipPosition="top"
styleClass="p-chip-sm" />
}
</div>
}

<div class="dot-category-field__select">
Expand Down

0 comments on commit f5ecf66

Please sign in to comment.