+
diff --git a/src/app/shared/truncatable/truncatable.component.spec.ts b/src/app/shared/truncatable/truncatable.component.spec.ts
index b539ab0d56..29100e50d2 100644
--- a/src/app/shared/truncatable/truncatable.component.spec.ts
+++ b/src/app/shared/truncatable/truncatable.component.spec.ts
@@ -70,15 +70,4 @@ describe('TruncatableComponent', () => {
});
});
- describe('When toggle is called', () => {
- beforeEach(() => {
- spyOn(truncatableService, 'toggle');
- comp.toggle();
- });
-
- it('should call toggle on the TruncatableService', () => {
- expect(truncatableService.toggle).toHaveBeenCalledWith(identifier);
- });
- });
-
});
diff --git a/src/app/shared/truncatable/truncatable.component.ts b/src/app/shared/truncatable/truncatable.component.ts
index e22ce4441e..61ec9c422a 100644
--- a/src/app/shared/truncatable/truncatable.component.ts
+++ b/src/app/shared/truncatable/truncatable.component.ts
@@ -1,6 +1,4 @@
-import {
- Component, Input
-} from '@angular/core';
+import { AfterViewChecked, Component, ElementRef, Input, OnInit } from '@angular/core';
import { TruncatableService } from './truncatable.service';
@Component({
@@ -13,7 +11,7 @@ import { TruncatableService } from './truncatable.service';
/**
* Component that represents a section with one or more truncatable parts that all listen to this state
*/
-export class TruncatableComponent {
+export class TruncatableComponent implements OnInit, AfterViewChecked {
/**
* Is true when all truncatable parts in this truncatable should be expanded on loading
*/
@@ -29,7 +27,7 @@ export class TruncatableComponent {
*/
@Input() onHover = false;
- public constructor(private service: TruncatableService) {
+ public constructor(private service: TruncatableService, private el: ElementRef,) {
}
/**
@@ -61,11 +59,14 @@ export class TruncatableComponent {
}
}
- /**
- * Expands the truncatable when it's collapsed, collapses it when it's expanded
- */
- public toggle() {
- this.service.toggle(this.id);
+ ngAfterViewChecked() {
+ const truncatedElements = this.el.nativeElement.querySelectorAll('.truncated');
+ if (truncatedElements?.length > 1) {
+ for (let i = 0; i < (truncatedElements.length - 1); i++) {
+ truncatedElements[i].classList.remove('truncated');
+ truncatedElements[i].classList.add('notruncatable');
+ }
+ }
}
}
diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5
index c3c68a6882..12de3ffdea 100644
--- a/src/assets/i18n/en.json5
+++ b/src/assets/i18n/en.json5
@@ -2056,6 +2056,10 @@
"item.search.title": "Item Search",
+ "item.truncatable-part.show-more": "Show more",
+
+ "item.truncatable-part.show-less": "Collapse",
+
"item.page.abstract": "Abstract",