diff --git a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.ts b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.ts index 0bfcf25d39..2c3cb925cd 100644 --- a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.ts +++ b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.ts @@ -116,23 +116,21 @@ export class TruncatablePartComponent implements AfterContentChecked, OnInit, On * Function to get data to be observed */ toObserve() { - this.observedContent = this.document.querySelectorAll('.content'); + this.observedContent = this.document.querySelectorAll('.content:not(.notruncatable)'); this.observer = new (this._window.nativeWindow as any).ResizeObserver((entries) => { for (let entry of entries) { - if (!entry.target.classList.contains('notruncatable')) { - if (entry.target.scrollHeight > entry.contentRect.height) { - if (entry.target.children.length > 0) { - if (entry.target.children[0].offsetHeight > entry.contentRect.height) { - entry.target.classList.add('truncated'); - } else { - entry.target.classList.remove('truncated'); - } - } else { + if (entry.target.scrollHeight > entry.contentRect.height) { + if (entry.target.children.length > 0) { + if (entry.target.children[entry.target.children.length - 1].offsetHeight > entry.contentRect.height) { entry.target.classList.add('truncated'); + } else { + entry.target.classList.remove('truncated'); } } else { - entry.target.classList.remove('truncated'); + entry.target.classList.add('truncated'); } + } else { + entry.target.classList.remove('truncated'); } } }); diff --git a/src/app/shared/truncatable/truncatable.component.ts b/src/app/shared/truncatable/truncatable.component.ts index 61ec9c422a..3f3b91b018 100644 --- a/src/app/shared/truncatable/truncatable.component.ts +++ b/src/app/shared/truncatable/truncatable.component.ts @@ -1,4 +1,4 @@ -import { AfterViewChecked, Component, ElementRef, Input, OnInit } from '@angular/core'; +import { AfterContentChecked, Component, ElementRef, Input, OnInit } from '@angular/core'; import { TruncatableService } from './truncatable.service'; @Component({ @@ -11,7 +11,7 @@ import { TruncatableService } from './truncatable.service'; /** * Component that represents a section with one or more truncatable parts that all listen to this state */ -export class TruncatableComponent implements OnInit, AfterViewChecked { +export class TruncatableComponent implements OnInit, AfterContentChecked { /** * Is true when all truncatable parts in this truncatable should be expanded on loading */ @@ -59,7 +59,7 @@ export class TruncatableComponent implements OnInit, AfterViewChecked { } } - ngAfterViewChecked() { + ngAfterContentChecked() { const truncatedElements = this.el.nativeElement.querySelectorAll('.truncated'); if (truncatedElements?.length > 1) { for (let i = 0; i < (truncatedElements.length - 1); i++) {