[DSC-516] Fix issue with sidebar search list element

This commit is contained in:
Giuseppe Digilio
2022-06-13 17:41:51 +02:00
parent b6f83461ab
commit 06d07dc1df
3 changed files with 44 additions and 28 deletions

View File

@@ -1,13 +1,13 @@
<ds-truncatable-part [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
<ds-truncatable-part [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'" [showToggle]="false">
<div [ngClass]="isCurrent() ? 'text-light' : 'text-body'"
[innerHTML]="(parentTitle$ && parentTitle$ | async) ? (parentTitle$ | async) : ('home.breadcrumbs' | translate)"></div>
</ds-truncatable-part>
<ds-truncatable-part *ngIf="title" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
<ds-truncatable-part *ngIf="title" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'" [showToggle]="false">
<div class="font-weight-bold"
[ngClass]="isCurrent() ? 'text-light' : 'text-primary'"
[innerHTML]="title"></div>
</ds-truncatable-part>
<ds-truncatable-part *ngIf="description" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
<ds-truncatable-part *ngIf="description" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'" [showToggle]="false">
<div class="text-secondary"
[ngClass]="isCurrent() ? 'text-light' : 'text-secondary'"
[innerHTML]="description"></div>

View File

@@ -40,6 +40,12 @@ export class TruncatablePartComponent implements AfterViewChecked, OnInit, OnDes
@Input() background = 'default';
/**
* A boolean representing if to show or not the show/collapse toggle.
* This value must have the same value as the parent TruncatableComponent
*/
@Input() showToggle = true;
/**
* The view on the truncatable part
*/
@@ -103,6 +109,7 @@ export class TruncatablePartComponent implements AfterViewChecked, OnInit, OnDes
* check for the truncate element
*/
public truncateElement() {
if (this.showToggle) {
const entry = this.content.nativeElement;
if (entry.scrollHeight > entry.offsetHeight) {
if (entry.children.length > 0) {
@@ -127,6 +134,7 @@ export class TruncatablePartComponent implements AfterViewChecked, OnInit, OnDes
entry.classList.add('removeFaded');
}
}
}
/**
* Unsubscribe from the subscription

View File

@@ -27,6 +27,12 @@ export class TruncatableComponent implements OnInit, AfterViewChecked {
*/
@Input() onHover = false;
/**
* A boolean representing if to show or not the show/collapse toggle
* This value must have the same value as the children TruncatablePartComponent
*/
@Input() showToggle = true;
public constructor(private service: TruncatableService, private el: ElementRef,) {
}
@@ -60,6 +66,7 @@ export class TruncatableComponent implements OnInit, AfterViewChecked {
}
ngAfterViewChecked() {
if (this.showToggle) {
const truncatedElements = this.el.nativeElement.querySelectorAll('.truncated');
if (truncatedElements?.length > 0) {
const truncateElements = this.el.nativeElement.querySelectorAll('.dont-break-out');
@@ -70,5 +77,6 @@ export class TruncatableComponent implements OnInit, AfterViewChecked {
truncateElements[truncateElements.length - 1].classList.add('truncated');
}
}
}
}