Skip to content

Commit 1f0d936

Browse files
authored
Merge pull request #5481 from DSpace/backport-4949-to-dspace-9_x
[Port dspace-9_x] [DURACOM-429] simplify truncatable calculation
2 parents 6a08010 + b1a9e8a commit 1f0d936

1 file changed

Lines changed: 4 additions & 18 deletions

File tree

src/app/shared/truncatable/truncatable-part/truncatable-part.component.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,10 @@ export class TruncatablePartComponent implements AfterViewChecked, OnInit, OnDes
127127
public truncateElement() {
128128
if (this.showToggle) {
129129
const entry = this.content.nativeElement;
130-
if (entry.scrollHeight > entry.offsetHeight) {
131-
if (entry.children.length > 0) {
132-
if (entry.children[entry.children.length - 1].offsetHeight > entry.offsetHeight) {
133-
entry.classList.add('truncated');
134-
entry.classList.remove('removeFaded');
135-
} else {
136-
entry.classList.remove('truncated');
137-
entry.classList.add('removeFaded');
138-
}
139-
} else {
140-
if (entry.innerText.length > 0) {
141-
entry.classList.add('truncated');
142-
entry.classList.remove('removeFaded');
143-
} else {
144-
entry.classList.remove('truncated');
145-
entry.classList.add('removeFaded');
146-
}
147-
}
130+
const isOverflowing = entry.scrollHeight > entry.clientHeight;
131+
if (isOverflowing) {
132+
entry.classList.add('truncated');
133+
entry.classList.remove('removeFaded');
148134
} else {
149135
entry.classList.remove('truncated');
150136
entry.classList.add('removeFaded');

0 commit comments

Comments
 (0)