Skip to content

Commit f83d972

Browse files
committed
fix: use safe navigation for model.context.label in form template
model.context might be undefined for default DSpace form array models that don't set context.label. Use optional chaining (?.) to prevent runtime crash, with fallback to form.add translation.
1 parent 99a9711 commit f83d972

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/app/shared/form/form.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
<div *ngIf="(!context.notRepeatable) && index === (group.context.groups.length - 1) && !isItemReadOnly(context, index)" class="clearfix pl-4 w-100">
2828
<div class="btn-group" role="group">
2929
<button type="button" role="button" class="ds-form-add-more btn btn-link"
30-
title="{{'form.add' | translate}} {{ model.context.label }}"
31-
attr.aria-label="{{'form.add' | translate}} {{ model.context.label }}"
30+
title="{{'form.add' | translate}} {{ model?.context?.label }}"
31+
attr.aria-label="{{'form.add' | translate}} {{ model?.context?.label }}"
3232
(click)="insertItem($event, group.context, group.context.groups.length)">
33-
<span><i class="fas fa-plus"></i>&nbsp;{{ model.context.label }}</span>
33+
<span><i class="fas fa-plus"></i>&nbsp;{{ model?.context?.label || ('form.add' | translate) }}</span>
3434
<!-- DATASHARE: Replaced {{'form.add' | translate}} with {{ model.context.label }} -->
3535
</button>
3636
</div>

0 commit comments

Comments
 (0)