@zambon-dev/library 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -23,6 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
23
 
24
24
  ### ⚠ Breaking Changes / Migration
25
25
 
26
+ ## [1.4.1] - 2026-09-08
27
+
28
+ - Maintenance release (no consumer-facing changes were documented).
29
+
26
30
  ## [1.4.0] - 2026-09-08
27
31
 
28
32
  ### Added
@@ -113,6 +117,18 @@ and want external items too, add a subscription to `menuExternalUrlSelected`.
113
117
  only the last one saved just that row, because `onSaveClick` validates the current selection only,
114
118
  so the earlier rows silently vanished on refresh. `newData()`'s values are now registered when the
115
119
  row is added.
120
+ - **`lib-catalog-select` no longer renders an empty caption after a form reset.** `FormService.resetForm()`
121
+ clears every control and then patches the model back, so the component receives the value it already
122
+ held. It skipped refreshing the caption in that case, on the assumption that an unchanged value means
123
+ the caption is still on screen — but the reset had emptied the display control a moment earlier. The
124
+ field therefore rendered blank whenever the stored value equalled the control's initial value, which
125
+ is why it only ever showed on the entry the form defaults to: a `nonNullable` control declared as
126
+ `new FormControl(0)` bound to an enum whose first member is `0`, for instance. Values differing from
127
+ the initial one refreshed normally and always looked right, which made the fault read like a
128
+ translation or data problem rather than a reset one. The caption is now rewritten whenever it has
129
+ drifted from the selected entry, so the value alone no longer decides. Selects backed by a
130
+ `searchEndpoint` are unaffected, since their caption comes from the server-side selection rather than
131
+ `entriesList`. No consumer changes are required.
116
132
 
117
133
  ### ⚠ Breaking Changes / Migration
118
134
 
@@ -200,7 +216,8 @@ config options and the `getUserProfile()` method still exist but are no longer c
200
216
  available via [GitHub Releases](https://github.com/RicardoZambon/ZLibraries/releases) and the
201
217
  `library-v*` tags.
202
218
 
203
- [Unreleased]: https://github.com/RicardoZambon/ZLibraries/compare/library-v1.4.0...HEAD
219
+ [Unreleased]: https://github.com/RicardoZambon/ZLibraries/compare/library-v1.4.1...HEAD
220
+ [1.4.1]: https://github.com/RicardoZambon/ZLibraries/releases/tag/library-v1.4.1
204
221
  [1.4.0]: https://github.com/RicardoZambon/ZLibraries/releases/tag/library-v1.4.0
205
222
  [1.3.2]: https://github.com/RicardoZambon/ZLibraries/releases/tag/library-v1.3.2
206
223
  [1.3.1]: https://github.com/RicardoZambon/ZLibraries/releases/tag/library-v1.3.1
@@ -1682,7 +1682,7 @@ class CatalogSelectComponent extends BaseComponent {
1682
1682
  .pipe(takeUntil(this.destroy$))
1683
1683
  .subscribe((value) => {
1684
1684
  this.syncFormControlsEnabledDisabled();
1685
- if (this.selectedValue === value) {
1685
+ if (!this.shouldRefreshDisplay(value)) {
1686
1686
  return;
1687
1687
  }
1688
1688
  this.selectedValue = value;
@@ -1692,8 +1692,7 @@ class CatalogSelectComponent extends BaseComponent {
1692
1692
  }
1693
1693
  }
1694
1694
  else {
1695
- const display = this.entriesDataSource.filter((entry) => entry.value === value)[0]?.display ?? '';
1696
- this.displayControl?.setValue(display, { emitEvent: false });
1695
+ this.displayControl?.setValue(this.resolveDisplay(value), { emitEvent: false });
1697
1696
  }
1698
1697
  });
1699
1698
  // Initial sync: if the form control already has a value (e.g., the model was loaded
@@ -1972,16 +1971,36 @@ class CatalogSelectComponent extends BaseComponent {
1972
1971
  this.showNoResultsMessage = false;
1973
1972
  this.showMinimumCharactersMessage = false;
1974
1973
  }
1974
+ resolveDisplay(value) {
1975
+ return this.entriesDataSource.filter((entry) => entry.value === value)[0]?.display ?? '';
1976
+ }
1975
1977
  syncDisplayFromCurrentValue() {
1976
1978
  const currentValue = this.formControl?.value;
1977
- if (currentValue == null || this.selectedValue === currentValue) {
1979
+ if (currentValue == null || !this.shouldRefreshDisplay(currentValue)) {
1978
1980
  return;
1979
1981
  }
1980
1982
  this.selectedValue = currentValue;
1981
1983
  if (!this.hasSearchEndpoint) {
1982
- const display = this.entriesDataSource.filter((entry) => entry.value === currentValue)[0]?.display ?? '';
1983
- this.displayControl?.setValue(display, { emitEvent: false });
1984
+ this.displayControl?.setValue(this.resolveDisplay(currentValue), { emitEvent: false });
1985
+ }
1986
+ }
1987
+ /**
1988
+ * Decides whether the display control has to be written again.
1989
+ *
1990
+ * The value on its own is not enough. Resetting a form clears the display control and then
1991
+ * patches the same value back, so an unchanged value can still leave the display empty. That
1992
+ * only happens when the stored value equals the control's initial value, which is why it used
1993
+ * to show up on the default entry alone.
1994
+ */
1995
+ shouldRefreshDisplay(value) {
1996
+ if (this.selectedValue !== value) {
1997
+ return true;
1998
+ }
1999
+ if (this.hasSearchEndpoint) {
2000
+ return false;
1984
2001
  }
2002
+ const display = this.resolveDisplay(value);
2003
+ return display.length > 0 && this.displayControl?.value !== display;
1985
2004
  }
1986
2005
  syncFormControlsEnabledDisabled() {
1987
2006
  if (this.formControl.enabled !== this.displayControl.enabled) {