@spartan-ng/brain 1.8.0 → 1.8.1-beta.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.
@@ -541,7 +541,13 @@ class BrnCalendarMonthSelect {
541
541
  const targetDate = this._dateAdapter.set(this._dateAdapter.startOfMonth(focusedDate), { month });
542
542
  const lastDay = this._dateAdapter.getDate(this._dateAdapter.endOfMonth(targetDate));
543
543
  const day = Math.min(this._dateAdapter.getDate(focusedDate), lastDay);
544
- this._calendar.setFocusedDate(this._dateAdapter.set(targetDate, { day }));
544
+ // Like the previous/next buttons, constrain the target to min/max instead of letting
545
+ // setFocusedDate reject it: otherwise the grid stays on the old month.
546
+ const target = this._calendar.constrainDate(this._dateAdapter.set(targetDate, { day }));
547
+ this._calendar.setFocusedDate(target);
548
+ // The select already shows the picked month. When the focused month did not change
549
+ // (target rejected or constrained back into it), the effect does not run again.
550
+ this._select.writeValue(this._selectedMonth());
545
551
  }
546
552
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMonthSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive });
547
553
  /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarMonthSelect, isStandalone: true, selector: "brnSelect[brnCalendarMonthSelect],hlm-select[brnCalendarMonthSelect]", exportAs: ["brnCalendarMonthSelect"], ngImport: i0 });
@@ -839,7 +845,12 @@ class BrnCalendarYearSelect {
839
845
  const targetDate = this._dateAdapter.set(this._dateAdapter.startOfMonth(focusedDate), { year });
840
846
  const lastDay = this._dateAdapter.getDate(this._dateAdapter.endOfMonth(targetDate));
841
847
  const day = Math.min(this._dateAdapter.getDate(focusedDate), lastDay);
842
- this._calendar.setFocusedDate(this._dateAdapter.set(targetDate, { day }));
848
+ // Like the previous/next buttons, constrain the target to min/max instead of letting
849
+ // setFocusedDate reject it: otherwise the grid stays on the old year.
850
+ const target = this._calendar.constrainDate(this._dateAdapter.set(targetDate, { day }));
851
+ this._calendar.setFocusedDate(target);
852
+ // Keep the select on the year actually shown when the target was rejected.
853
+ this._select.writeValue(this._dateAdapter.getYear(this._calendar.focusedDate()));
843
854
  }
844
855
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarYearSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive });
845
856
  /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarYearSelect, isStandalone: true, selector: "brnSelect[brnCalendarYearSelect],hlm-select[brnCalendarYearSelect]", exportAs: ["brnCalendarYearSelect"], ngImport: i0 });