UoE/fix: preserve metadata form values when toggling submission sections#4
Open
milanmajchrak wants to merge 1 commit intodatashare-UoEMainLibrary-dspace-8_xfrom
Open
Conversation
There was a problem hiding this comment.
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
*ngIffrom thengbPanelContenttemplate so[destroyOnHide]="false"can preserve component state. - Updated the datashare submission service spec to reference
DatashareSubmissionServiceconsistently (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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.htmltemplate had a conflicting combinationof directives:
[destroyOnHide]="false"tells ng-bootstrap: when a panel is collapsed,keep its DOM alive (hidden via CSS)
*ngIfon the content template tells Angular: remove this DOM entirelywhen the condition is false
The
*ngIfoverrodedestroyOnHide, causing the form component to bedestroyed on collapse and re-created on expand. The new instance would
re-initialise from server data, losing any unsaved user input.
Fix
Removed the
*ngIffrom 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 theDatashareSubmissionFormSectionContainerServicesignal. This is unaffected.With
[destroyOnHide]="false", collapsed sections are hidden via CSS(
display: none), not removed from the DOM — the same approach used byupstream DSpace Angular. The
*ngIfwas a redundant and destructive duplicateof what
[destroyOnHide]="false"already handles correctly.Changed files
src/app/submission/sections/container/section-container.component.html*ngIffromngbPanelContentsrc/app/datashare/datashare-submission.service.spec.tsDatashareCustomisedSubmissionService→DatashareSubmissionService)This is how it is working now:
fix-metadata-values-persist-after-toggle.webm