Skip to content

Commit 86348fb

Browse files
FrancescoMolinaroatarix83
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-2608 (pull request DSpace#3898)
[DSC-2608] refactor truncatable part check Approved-by: Giuseppe Digilio
2 parents 7709400 + e427f99 commit 86348fb

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
@@ -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)