Skip to content

fix(submission): keep dc.type dropdown display after change#157

Open
kosarko wants to merge 3 commits into
clarin-v7from
worktree-1377-item-type-dropdown
Open

fix(submission): keep dc.type dropdown display after change#157
kosarko wants to merge 3 commits into
clarin-v7from
worktree-1377-item-type-dropdown

Conversation

@kosarko

@kosarko kosarko commented Jun 24, 2026

Copy link
Copy Markdown
Member

resolves #156
(originally as ufal/clarin-dspace#1377)

Add a fakeAsync regression test that drives an empty-display value through group.valueChanges (the real reload entry point) and asserts the rendered input keeps its text, reproducing the original blank-after-latency bug.

Problem description

The "type of resource" scrollable dropdown blanked out after changing its value when the backend was slow: the reloaded model value came back with an empty display but populated value/authority, so currentValue rendered ''. Fall back to the underlying value when display is empty, matching the existing inputFormatter convention.

Copilot review

  • Requested review from Copilot

(ufal/clarin-dspace#1377 -> #156)

The "type of resource" scrollable dropdown blanked out after changing its
value when the backend was slow: the reloaded model value came back with an
empty display but populated value/authority, so currentValue rendered ''.
Fall back to the underlying value when display is empty, matching the
existing inputFormatter convention.

Add a fakeAsync regression test that drives an empty-display value through
group.valueChanges (the real reload entry point) and asserts the rendered
input keeps its text, reproducing the original blank-after-latency bug.

Copilot AI left a comment

Copy link
Copy Markdown

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 submission UI regression where the dc.type “type of resource” scrollable dropdown could blank out after a value change when the reloaded value had an empty display but a populated value/authority. The component now falls back to the underlying value when display is empty, consistent with the existing inputFormatter behavior.

Changes:

  • Update setCurrentValue to use display || value (both on init and on subsequent value changes).
  • Add unit/regression tests (including a fakeAsync case) to ensure the rendered <input> keeps its text when a value with empty display arrives via valueChanges.

Reviewed changes

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

File Description
src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts Ensures currentValue displayed in the dropdown input falls back to value when display is empty (init + updates).
src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts Adds regression coverage for empty-display values, including the valueChanges-driven reload scenario.

});

it('should fall back to the underlying value when display is empty on init', () => {
spyOn(vocabularyServiceStub, 'getVocabularyEntryByID').and.returnValue(observableOf(new VocabularyEntry()));
Address Copilot PR review: the init-path test previously relied on
isNotEmpty(new VocabularyEntry()) being false so getInitValueFromModel would
fall back to the raw model.value. That couples the test to VocabularyEntry
having no initialized fields. Stub getInitValueFromModel directly to emit an
empty-display value (built bypassing the FFMVO constructor, which would
otherwise fill display via `display || value`), so the test deterministically
exercises the setCurrentValue fallback it is meant to guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

The DSDynamicTypeBindRelationService spec called spyOn() on
formBuilderService.getTypeBindModel / getTypeBindModelUpdates, but the mock
(getMockFormBuilderService) already creates those as jasmine spies via
createSpyObj. Because src/test.ts runs with teardown.destroyAfterEach:false
and karma randomizes spec order, certain orderings hit the second spy
installation and threw "getTypeBindModel has already been spied upon",
failing 6 tests non-deterministically (green on clarin-v7, red here only due
to a different random ordering). Reconfigure the existing spies with .and.*
instead of re-spying, which is order-independent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Issues with creating new item

2 participants