Skip to content

Commit 77a8984

Browse files
authored
Merge pull request DSpace#4949 from 4Science/task/main/DURACOM-429
[DURACOM-429] simplify truncatable calculation
2 parents c3fce61 + 0b89868 commit 77a8984

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

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)