Skip to content

Commit

Permalink
Refactor #1802
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Nov 24, 2021
1 parent 64c5eee commit 8d4e59b
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/components/calendar/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,8 @@ export default {
}
//enter
case 13: {
case 13:
case 32: {
this.onDateSelect(event, date);
event.preventDefault();
break;
Expand Down Expand Up @@ -1793,7 +1794,7 @@ export default {
}
else {
let prevMonthContainer = this.$refs.overlay.children[groupIndex - 1];
let cells = DomHandler.find(prevMonthContainer, '.p-datepicker-calendar td span:not(.p-disabled)');
let cells = DomHandler.find(prevMonthContainer, '.p-datepicker-calendar td span:not(.p-disabled):not(.p-ink)');
let focusCell = cells[cells.length - 1];
focusCell.tabIndex = '0';
focusCell.focus();
Expand All @@ -1806,7 +1807,7 @@ export default {
}
else {
let nextMonthContainer = this.$refs.overlay.children[groupIndex + 1];
let focusCell = DomHandler.findSingle(nextMonthContainer, '.p-datepicker-calendar td span:not(.p-disabled)');
let focusCell = DomHandler.findSingle(nextMonthContainer, '.p-datepicker-calendar td span:not(.p-disabled):not(.p-ink');
focusCell.tabIndex = '0';
focusCell.focus();
}
Expand Down Expand Up @@ -1839,6 +1840,10 @@ export default {
prevCell.tabIndex = '0';
prevCell.focus();
}
else {
this.navigationState = {backward: true};
this.navBackward(event);
}
event.preventDefault();
break;
}
Expand All @@ -1851,12 +1856,17 @@ export default {
nextCell.tabIndex = '0';
nextCell.focus();
}
else {
this.navigationState = {backward: false};
this.navForward(event);
}
event.preventDefault();
break;
}
//enter
case 13: {
case 13:
case 32: {
this.onMonthSelect(event, index);
event.preventDefault();
break;
Expand Down Expand Up @@ -1891,7 +1901,7 @@ export default {
cell.tabIndex = '-1';
var cells = cell.parentElement.children;
var cellIndex = DomHandler.index(cell);
let nextCell = cells[event.which === 40 ? cellIndex + 3 : cellIndex -3];
let nextCell = cells[event.which === 40 ? cellIndex + 3 : cellIndex - 2];
if (nextCell) {
nextCell.tabIndex = '0';
nextCell.focus();
Expand All @@ -1907,6 +1917,10 @@ export default {
prevCell.tabIndex = '0';
prevCell.focus();
}
else {
this.navigationState = {backward: true};
this.navBackward(event);
}
event.preventDefault();
break;
}
Expand All @@ -1918,11 +1932,16 @@ export default {
nextCell.tabIndex = '0';
nextCell.focus();
}
else {
this.navigationState = {backward: false};
this.navForward(event);
}
event.preventDefault();
break;
}
//enter
case 13: {
case 13:
case 32: {
this.onMonthSelect(event, index);
event.preventDefault();
break;
Expand Down Expand Up @@ -2009,16 +2028,20 @@ export default {
else {
cell = DomHandler.findSingle(this.$refs.overlay, 'span.p-highlight');
if (!cell) {
let todayCell = DomHandler.findSingle(this.$refs.overlay, 'td.p-datepicker-today span:not(.p-disabled)');
let todayCell = DomHandler.findSingle(this.$refs.overlay, 'td.p-datepicker-today span:not(.p-disabled):not(.p-ink)');
if (todayCell)
cell = todayCell;
else
cell = DomHandler.findSingle(this.$refs.overlay, '.p-datepicker-calendar td span:not(.p-disabled)');
cell = DomHandler.findSingle(this.$refs.overlay, '.p-datepicker-calendar td span:not(.p-disabled):not(.p-ink');
}
}
if (cell) {
cell.tabIndex = '0';
if (!this.navigationState || !this.navigationState.button) {
cell.focus();
}
}
},
trapFocus(event) {
Expand Down

0 comments on commit 8d4e59b

Please sign in to comment.