Bonjour à tous

Quand je clique à la souris sur "Sélectionner une date", le datepicker s'ouvre correctement.
Mais après avoir positionné le curseur sur le text, quand j’appuie sur ENTREE ou ESPACE, il ne se produit rien du tout.
Si j'ajoute type="button", alors là, ça fonctionne, mais alors le texte "Sélectionner une date" disparait.
Je dois passer à côté de quelque chose de très gros, mais le nez dans le guidon, je ne trouve pas.
Si une bonne âme à la solution ?
Merci d'avance.

Voici mon code :

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<div class="calendar" [formGroup]="applyFilterForm">
  <i [ngClass]="{
    'fa fa-caret-left fa-4 previous': true,
    'disabled': !currentLayer ? true : null
    }" (click)="previousDate()"></i>
  <input tabindex="0" formControlName="calendarControl" [ngClass]="{
      'daterangepicker': true,
      'disabled': !currentLayer ? true : null
    }" readonly="readonly" (bsValueChange)="onValueChange($event)" bsDaterangepicker [bsConfig]="bsConfig"
    placeholder="Sélectionner une date" [attr.disabled]="!currentLayer ? true : null" />
  <i [ngClass]="{
      'fa fa-caret-right fa-4 next': true,
      'disabled': !currentLayer ? true : null
      }" (click)="nextDate()"></i>
</div>

Code css : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
.daterangepicker {
  height: 30px;
  color: white;
  cursor: pointer;
  width: 180px;
  background-color: transparent;
  border-radius: 0%;
  /*font-size: 16px;*/
  font-size: 14px;
  border: none;
  padding: 0;
}
 
.calendar {
  margin-top: 0rem;
}
 
.next {
  margin-left: 0.5rem;
  margin-top: 0.3rem;
}
 
.previous {
  margin-right: 0.5rem;
  margin-top: 0.3rem;
}
 
i {
  cursor: pointer;
}
 
.daterangepicker {
  opacity: 1; /* Firefox */
  text-align: center;
}
 
/* Smartphones (portrait and landscape) */
 
/* landscape */
@media  only screen and (max-width : 900px) {
  /**
 * Margin for the calendar.
 */
  ::ng-deep body > bs-daterangepicker-container {
    /* left: -0.1rem !important; */
    left: -0.1rem !important;
    top: 16rem !important;
  }
 
  /**
   * Calendar.
   */
  ::ng-deep body > bs-daterangepicker-container > div {
    box-shadow: 0 0 5px 0 #aaa !important;
    margin-left: 2rem;
    margin-top: -1rem;
  }
}
 
/* portrait */
@media  only screen and (max-width : 900px) and (min-width: 500px) {
  ::ng-deep body > bs-daterangepicker-container {
    left: 180px !important;
    top: 25px !important;
  }
}
 
.daterangepicker.disabled::placeholder {
  color: #6c757d;
}
 
.daterangepicker::placeholder {
  color: white;
}
 
.disabled {
  cursor: not-allowed;
}

Code typescript : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import { FilterTrafficName } from 'src/app/shared/app/enums';
import { FilterTrafficItem, FiltersLayerWithMode } from '@shared-app/model/filter-traffic.model';
import { FiltersTrafficService } from '@shared-app/store/filters/traffic/filters-traffic.service';
import { Component, OnInit, Input, ChangeDetectionStrategy, ChangeDetectorRef, OnChanges, SimpleChanges } from '@angular/core';
import { UntypedFormGroup, AbstractControl } from '@angular/forms';
import { BsDatepickerConfig, BsLocaleService } from 'ngx-bootstrap/datepicker';
 
// The hour doesn't convert correctly. The system hour is conserved.
// The date set by component does not change. This is the behavior wished.
import { defineLocale } from 'ngx-bootstrap/chronos';
import { frLocale } from 'ngx-bootstrap/locale';
defineLocale('fr', frLocale);
// Into the constructor : BsLocaleService..use('fr')
 
/**
 * Calendar component.
 */
@Component({
  selector: 'app-calendar',
  templateUrl: './calendar.component.html',
  styleUrls: ['./calendar.component.css'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class CalendarComponent implements OnInit, OnChanges {
  /**
   * Configuration object for the calendar parameters.
   */
  bsConfig: Partial<BsDatepickerConfig> = { isAnimated: true, containerClass: 'theme-orange', rangeInputFormat: 'DD/MM/YYYY', adaptivePosition: true };
 
  /**
   * Ref. to the form.
   */
  @Input() applyFilterForm: UntypedFormGroup;
  /**
   * Reinit the calendar binding.
   */
  @Input() reinitCalendar: boolean;
  /**
   * The binding of the current layer.
   */
  private pCurrentLayer: FiltersLayerWithMode;
 
  /**
   * Ref. to the form control calendar.
   */
  calendarControl: AbstractControl;
 
 
  /**
   * Constructor.
   *
   * @param calendarManager the calendar service
   */
  constructor(
    private filtersService: FiltersTrafficService,
    private bsLocale: BsLocaleService,
    private cd: ChangeDetectorRef) {
    this.bsLocale.use('fr');
  }
 
  /**
   * On init comp.
   */
  ngOnInit() {
    this.calendarControl = this.f.calendarControl;
 
    if (this.filtersService.isDateDefinedIntoCurrentFilterLayer()) {
      const [startDate, endDate] = this.filtersService.getDateFromCurrentFilterLayer();
      this.calendarControl.setValue([startDate, endDate]);
    }
  }
 
  /**
   * On changes comp attributes.
   */
  ngOnChanges(changes: SimpleChanges): void {
    const needChanges = changes.reinitCalendar;
    if (needChanges && needChanges.previousValue !== needChanges.currentValue && needChanges.currentValue === true) {
      if (this.calendarControl) {
        this.calendarControl.setValue(null);
      }
    }
  }
 
  get currentLayer() {
    return this.pCurrentLayer;
  }
 
  @Input()
  set currentLayer(layer: FiltersLayerWithMode) {
    this.pCurrentLayer = layer;
    if (!this.filtersService.isDateDefinedIntoCurrentFilterLayer()) {
      return;
    }
    if (!layer) {
      if (this.calendarControl) {
        this.calendarControl.setValue(null);
      }
    } else {
      const [startDate, endDate] = this.filtersService.getDateFromCurrentFilterLayer();
      this.calendarControl.setValue([startDate, endDate]);
    }
    this.cd.detectChanges();
  }
 
  /**
   * Handler when the range date changes.
   *
   * @param value the new range date
   */
  onValueChange(value: Array<Date>) {
    if (!value || this.filtersService.isValueEqualsFromCurrent(value)) {
      return;
    }
 
    this.filtersService.addOrUpdateFilterDateToCurrentLayer(new FilterTrafficItem(0, FilterTrafficName.DATE, value, ''));
  }
 
  /**
   * Set the previous date.
   */
  previousDate() {
    const value: Array<Date> = [this.addDays(this.calendarControl.value[0], -1), this.addDays(this.calendarControl.value[1], -1)];
    this.calendarControl.setValue(value);
    this.filtersService.addOrUpdateFilterDateToCurrentLayer(new FilterTrafficItem(0, FilterTrafficName.DATE, value, ''));
  }
 
  /**
   * Set the next date.
   */
  nextDate() {
    const value: Array<Date> = [this.addDays(this.calendarControl.value[0], 1), this.addDays(this.calendarControl.value[1], 1)];
    this.calendarControl.setValue(value);
    this.filtersService.addOrUpdateFilterDateToCurrentLayer(new FilterTrafficItem(0, FilterTrafficName.DATE, value, ''));
  }
 
  /**
   * Returns an object reference of the controls of form.
   * Each control is accessibe by its name as key and the value returned as a FormControl.
   *
   * @returns an object of each control of form
   */
  get f(): { [key: string]: AbstractControl } {
    return this.applyFilterForm.controls;
  }
 
  /**
   * Add days to the given date.
   *
   * @param date the date
   * @param days the number of days
   * @return the new date
   */
  private addDays(date: Date, days: number) {
    const copy = new Date(+date);
    copy.setDate(date.getDate() + days);
    return copy;
  }
 
}