i-tech-shared-components 1.4.55 → 1.4.56-alpha.1770835262212

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.
@@ -1539,7 +1539,6 @@ class DateRangeDatepickerComponent {
1539
1539
  this.isOpen = false;
1540
1540
  this.isSelectingRange = false;
1541
1541
  this.LabelTypeEnum = LabelTypeEnum;
1542
- this.calendarClickCount = 0;
1543
1542
  this.dateRangeForm = new UntypedFormGroup({
1544
1543
  startDate: new UntypedFormControl('', [Validators.maxLength(10)]),
1545
1544
  endDate: new UntypedFormControl('', [Validators.maxLength(10)]),
@@ -1600,6 +1599,7 @@ class DateRangeDatepickerComponent {
1600
1599
  this.isSelectingRange = false;
1601
1600
  if (startDate === null && endDate === null) {
1602
1601
  this.dateRangeForm.reset();
1602
+ this.picker.select(null);
1603
1603
  this.selectionChange.emit(value);
1604
1604
  }
1605
1605
  else if (startDate && endDate) {
@@ -1621,31 +1621,25 @@ class DateRangeDatepickerComponent {
1621
1621
  this.isOpen = true;
1622
1622
  if (this.presetActions?.length) {
1623
1623
  this.selectionSub?.unsubscribe();
1624
- this.calendarClickCount = 0;
1625
- // Wait for picker content to render, then subscribe to calendar user selections
1626
- setTimeout(() => {
1627
- const content = this.picker._componentRef?.instance;
1628
- const calendar = content?._calendar;
1629
- if (calendar) {
1630
- this.selectionSub = calendar._userSelection.subscribe(() => {
1631
- this.calendarClickCount++;
1632
- // Only check after at least 2 clicks (start + end) to avoid
1633
- // false positives from old model selection on the first click
1634
- if (this.calendarClickCount >= 2) {
1635
- setTimeout(() => {
1636
- const selection = this.picker._model?.selection;
1637
- if (selection?.start && selection?.end) {
1638
- this.calendarClickCount = 0;
1639
- const applyBtn = document.querySelector('.hidden-apply-btn');
1640
- if (applyBtn) {
1641
- applyBtn.click();
1642
- }
1643
- }
1644
- }, 50);
1645
- }
1646
- });
1647
- }
1648
- }, 200);
1624
+ let rangeStarted = false;
1625
+ const model = this.picker._model;
1626
+ if (model) {
1627
+ this.selectionSub = model.selectionChanged.subscribe((change) => {
1628
+ const selection = change?.selection;
1629
+ if (selection?.start && !selection?.end) {
1630
+ rangeStarted = true;
1631
+ }
1632
+ else if (selection?.start && selection?.end && rangeStarted) {
1633
+ rangeStarted = false;
1634
+ setTimeout(() => {
1635
+ const applyBtn = document.querySelector('.hidden-apply-btn');
1636
+ if (applyBtn) {
1637
+ applyBtn.click();
1638
+ }
1639
+ });
1640
+ }
1641
+ });
1642
+ }
1649
1643
  }
1650
1644
  }
1651
1645
  onPickerClosed() {