Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opening ds-metadata-uri-values links in a new window #2866

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
}
Loading