Skip to content

Commit d6f49e2

Browse files
[DSC-2608] refactor truncatable part check
1 parent bd1b808 commit d6f49e2

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
@@ -111,24 +111,10 @@ export class TruncatablePartComponent implements AfterViewChecked, OnInit, OnDes
111111
public truncateElement() {
112112
if (this.showToggle) {
113113
const entry = this.content.nativeElement;
114-
if (entry.scrollHeight > entry.offsetHeight) {
115-
if (entry.children.length > 0) {
116-
if (entry.children[entry.children.length - 1].offsetHeight > entry.offsetHeight) {
117-
entry.classList.add('truncated');
118-
entry.classList.remove('removeFaded');
119-
} else {
120-
entry.classList.remove('truncated');
121-
entry.classList.add('removeFaded');
122-
}
123-
} else {
124-
if (entry.innerText.length > 0) {
125-
entry.classList.add('truncated');
126-
entry.classList.remove('removeFaded');
127-
} else {
128-
entry.classList.remove('truncated');
129-
entry.classList.add('removeFaded');
130-
}
131-
}
114+
const isOverflowing = entry.scrollHeight > entry.clientHeight;
115+
if (isOverflowing) {
116+
entry.classList.add('truncated');
117+
entry.classList.remove('removeFaded');
132118
} else {
133119
entry.classList.remove('truncated');
134120
entry.classList.add('removeFaded');

0 commit comments

Comments
 (0)