Skip to content

Commit 9bf6560

Browse files
committed
feat(Calendar): remove tabIndex from the component itself #6275
1 parent 57c73ca commit 9bf6560

File tree

7 files changed

+22
-46
lines changed

7 files changed

+22
-46
lines changed

Diff for: projects/igniteui-angular/src/lib/calendar/calendar.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ <h2 class="igx-calendar__header-date">
4545

4646
<div style="display: flex"
4747
[@animateChange]="animationAction"
48-
(@animateChange.done)="animationDone($event)" >
48+
(@animateChange.done)="animationDone($event)" (pointerup)="$event.stopPropagation()" >
4949
<igx-days-view *ngFor="let view of monthsViewNumber | IgxMonthViewSlots; index as i;" [changeDaysView]="true" #days
5050
[selection]="selection"
5151
[locale]="locale"

Diff for: projects/igniteui-angular/src/lib/calendar/calendar.component.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,6 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
191191
*/
192192
public callback: (next) => void;
193193

194-
/**
195-
* The default `tabindex` attribute for the component.
196-
*
197-
* @hidden
198-
* @internal
199-
*/
200-
@HostBinding('attr.tabindex')
201-
public tabindex = 0;
202-
203194
/**
204195
* The default aria role attribute for the component.
205196
*
@@ -782,7 +773,7 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
782773
public resetActiveDate() {
783774
if (!this.monthViews) { return; }
784775
let dates = [];
785-
this.monthViews.map(mv => mv.dates).forEach(days => { dates = dates.concat(days.toArray()); });
776+
this.monthViews.map(mv => mv.dates).forEach(days => { dates = dates.concat(days.toArray()); });
786777
const date = dates.find(day => day.selected && day.isCurrentMonth) || dates.find(day => day.isToday && day.isCurrentMonth)
787778
|| dates.find(d => d.isFocusable);
788779
if (date) {
@@ -943,12 +934,17 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
943934
}
944935
}
945936

946-
@HostListener('focusout', ['$event'])
947-
public onPointerDown(event) {
948-
/* if (event.path.contains('igx-days-view')) {
949-
return;
950-
} */
951-
console.log(event);
937+
@HostListener('document:pointerup')
938+
public pointerUp() {
939+
this.resetActiveDate();
940+
}
941+
942+
@HostListener('keydown.tab', ['$event'])
943+
@HostListener('keydown.shift.tab', ['$event'])
944+
public onTab(event) {
945+
if (event.target.tagName.toLowerCase() === 'igx-day-item') {
946+
requestAnimationFrame(() => this.resetActiveDate());
947+
}
952948
}
953949

954950
/**

Diff for: projects/igniteui-angular/src/lib/calendar/month-picker-base.ts

-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ export class IgxMonthPickerBaseDirective extends IgxCalendarBaseDirective {
2121
*/
2222
protected activeViewIdx = 0;
2323

24-
/**
25-
* The default `tabindex` attribute for the component.
26-
*
27-
* @hidden
28-
*/
29-
@HostBinding('attr.tabindex')
30-
public tabindex = 0;
31-
3224
/**
3325
* @hidden
3426
*/

Diff for: projects/igniteui-angular/src/lib/calendar/months-view/months-view.component.ts

-10
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,6 @@ export class IgxMonthsViewComponent implements ControlValueAccessor {
139139
@ViewChildren(IgxCalendarMonthDirective, { read: IgxCalendarMonthDirective })
140140
public monthsRef: QueryList<IgxCalendarMonthDirective>;
141141

142-
143-
/**
144-
* Gets/sets the `tabindex` attribute for the component.
145-
* Default value is 0
146-
*
147-
*/
148-
@Input()
149-
@HostBinding('attr.tabindex')
150-
public tabindex = 0;
151-
152142
/**
153143
* Returns an array of date objects which are then used to
154144
* properly render the month names.

Diff for: projects/igniteui-angular/src/lib/calendar/years-view/years-view.component.ts

-9
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,6 @@ export class IgxYearsViewComponent implements ControlValueAccessor {
134134
@HostBinding('class.igx-calendar')
135135
public styleClass = true;
136136

137-
/**
138-
* The default `tabindex` attribute for the component.
139-
*
140-
* @hidden
141-
*/
142-
@Input()
143-
@HostBinding('attr.tabindex')
144-
public tabindex = 0;
145-
146137
/**
147138
* Returns an array of date objects which are then used to properly
148139
* render the years.

Diff for: src/app/calendar/calendar.sample.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
<article class="sample-column">
55

66
<div class="calendar-sample">
7+
{{cal.activeDate}}
78
<h4 class="sample-title">Calendar Sample (NO Card wrapper)</h4>
8-
<igx-calendar weekStart="1" selection="multi" [hideOutsideDays]="false" [monthsViewNumber]="2"></igx-calendar>
9+
<igx-calendar #cal weekStart="1" selection="multi" [hideOutsideDays]="false" [monthsViewNumber]="2"></igx-calendar>
910
</div>
1011

1112
<div class="calendar-sample">
@@ -21,6 +22,7 @@ <h4 class="sample-title">Default Calendar</h4>
2122
<button igxButton="raised" igxRipple (click)="setSelection('single')">Single</button>
2223
<button igxButton="raised" igxRipple (click)="setSelection('multi')">Multi</button>
2324
<button igxButton="raised" igxRipple (click)="setSelection('range')">Range</button>
25+
{{calendar.activeDate}}
2426
</div>
2527
<igx-card>
2628
<igx-calendar #calendar [showWeekNumbers]="true" weekStart="1" selection="multi" (viewDateChanged)="viewDateChanged($event)" (activeViewChanged)="activeViewChanged($event)" (onSelection)="onSelection($event)" [hideOutsideDays]="false" [monthsViewNumber]="3"></igx-calendar>

Diff for: src/app/calendar/calendar.sample.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ export class CalendarSampleComponent implements OnInit, AfterViewInit {
7979
}
8080

8181
public select() {
82-
this.calendar.selectDate(new Date(this.today.getFullYear(), this.today.getMonth() + 1, 11));
82+
if (this.calendar.selection === 'single') {
83+
this.calendar.selectDate(new Date(this.today.getFullYear(), this.today.getMonth() + 1, 11));
84+
} else {
85+
this.calendar.selectDate([new Date(this.today.getFullYear(), this.today.getMonth(), 10),
86+
new Date(this.today.getFullYear(), this.today.getMonth(), 13)]);
87+
}
8388
}
8489

8590
public deselect() {

0 commit comments

Comments
 (0)