Skip to content

Commit 13dab8b

Browse files
authored
Merge pull request #5480 from DSpace/backport-4949-to-dspace-8_x
[Port dspace-8_x] [DURACOM-429] simplify truncatable calculation
2 parents 50393b3 + 95c30c2 commit 13dab8b

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
@@ -125,24 +125,10 @@ export class TruncatablePartComponent implements AfterViewChecked, OnInit, OnDes
125125
public truncateElement() {
126126
if (this.showToggle) {
127127
const entry = this.content.nativeElement;
128-
if (entry.scrollHeight > entry.offsetHeight) {
129-
if (entry.children.length > 0) {
130-
if (entry.children[entry.children.length - 1].offsetHeight > entry.offsetHeight) {
131-
entry.classList.add('truncated');
132-
entry.classList.remove('removeFaded');
133-
} else {
134-
entry.classList.remove('truncated');
135-
entry.classList.add('removeFaded');
136-
}
137-
} else {
138-
if (entry.innerText.length > 0) {
139-
entry.classList.add('truncated');
140-
entry.classList.remove('removeFaded');
141-
} else {
142-
entry.classList.remove('truncated');
143-
entry.classList.add('removeFaded');
144-
}
145-
}
128+
const isOverflowing = entry.scrollHeight > entry.clientHeight;
129+
if (isOverflowing) {
130+
entry.classList.add('truncated');
131+
entry.classList.remove('removeFaded');
146132
} else {
147133
entry.classList.remove('truncated');
148134
entry.classList.add('removeFaded');

0 commit comments

Comments
 (0)