Skip to content

UoE/fix: preserve metadata form values when toggling submission sections#4

Open
milanmajchrak wants to merge 1 commit intodatashare-UoEMainLibrary-dspace-8_xfrom
uoe/item-issue-metadata-value-is-lost
Open

UoE/fix: preserve metadata form values when toggling submission sections#4
milanmajchrak wants to merge 1 commit intodatashare-UoEMainLibrary-dspace-8_xfrom
uoe/item-issue-metadata-value-is-lost

Conversation

@milanmajchrak
Copy link
Copy Markdown
Collaborator

@milanmajchrak milanmajchrak commented Apr 9, 2026

Problem

When creating a new Item submission, entering values in metadata fields
(e.g. Title, Description), then collapsing and re-expanding the Metadata
section, all entered values would disappear.

Root cause

The section-container.component.html template had a conflicting combination
of directives:

<ngb-accordion [destroyOnHide]="false" ...>
  <ng-template ngbPanelContent
    *ngIf="datashareSubmissionFormSectionContainerService.openPanelId() === sectionData.id || ''">
  • [destroyOnHide]="false" tells ng-bootstrap: when a panel is collapsed,
    keep its DOM alive (hidden via CSS)
  • *ngIf on the content template tells Angular: remove this DOM entirely
    when the condition is false

The *ngIf overrode destroyOnHide, causing the form component to be
destroyed on collapse and re-created on expand. The new instance would
re-initialise from server data, losing any unsaved user input.

Fix

Removed the *ngIf from the <ng-template ngbPanelContent> line.

Why this doesn't break anything

The single-section-open-at-a-time behaviour is controlled entirely by the
[activeIds] binding on <ngb-accordion>, driven by the
DatashareSubmissionFormSectionContainerService signal. This is unaffected.

With [destroyOnHide]="false", collapsed sections are hidden via CSS
(display: none), not removed from the DOM — the same approach used by
upstream DSpace Angular. The *ngIf was a redundant and destructive duplicate
of what [destroyOnHide]="false" already handles correctly.

Changed files

File Change
src/app/submission/sections/container/section-container.component.html Removed *ngIf from ngbPanelContent
src/app/datashare/datashare-submission.service.spec.ts Fixed pre-existing broken import (DatashareCustomisedSubmissionServiceDatashareSubmissionService)

This is how it is working now:
fix-metadata-values-persist-after-toggle.webm

Copilot AI review requested due to automatic review settings April 9, 2026 09:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a UX issue in the submission UI where collapsing/re-expanding the Metadata accordion section cleared unsaved form inputs by preventing Angular from destroying the panel content DOM on collapse.

Changes:

  • Removed a conflicting *ngIf from the ngbPanelContent template so [destroyOnHide]="false" can preserve component state.
  • Updated the datashare submission service spec to reference DatashareSubmissionService consistently (import, describe, injection).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/app/submission/sections/container/section-container.component.html Stops accordion panel content from being torn down on collapse, preserving in-progress form values.
src/app/datashare/datashare-submission.service.spec.ts Aligns the unit test with the actual service name being tested/injected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/app/datashare/datashare-submission.service.spec.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants