Skip to content

Commit

Permalink
113124: Allow opening ds-metadata-uri-values links in a new window
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuno Vercammen committed Mar 15, 2024
1 parent 4c693a1 commit badf002
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ds-metadata-field-wrapper [label]="label | translate">
<a class="dont-break-out" *ngFor="let mdValue of mdValues; let last=last;" [href]="mdValue.value">
<a class="dont-break-out" *ngFor="let mdValue of mdValues; let last=last;" [href]="mdValue.value" [target]="linkTarget">
{{ linktext || mdValue.value }}<span *ngIf="!last" [innerHTML]="separator"></span>
</a>
</ds-metadata-field-wrapper>
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ describe('MetadataUriValuesComponent', () => {
expect(separators.length).toBe(mockMetadata.length - 1);
});

it('should contain the correct target attribute for metadata links', () => {
const links = fixture.debugElement.queryAll(By.css('a'));
for (const link of links) {
expect(link.nativeElement.getAttribute('target')).toBe('_blank');
}
});

describe('when linktext is defined', () => {

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ export class MetadataUriValuesComponent extends MetadataValuesComponent {
* The label for this iteration of metadata values
*/
@Input() label: string;

/**
* The target attribute for the metadata links.
* Defaults to '_blank' to open links in a new window/tab.
*/
@Input() linkTarget = '_blank';
}

0 comments on commit badf002

Please sign in to comment.