@syncfusion/ej2-calendars 33.2.12 → 33.2.15

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.
@@ -645,32 +645,29 @@ var CalendarBase = /** @__PURE__ @class */ (function (_super) {
645
645
  break;
646
646
  case 'tab':
647
647
  if (this.getModuleName() === 'datepicker' || this.getModuleName() === 'datetimepicker') {
648
- var hasToday = this.showTodayButton && !isNullOrUndefined(this.todayElement);
649
- var isLastFocusable = hasToday
650
- ? (e.target === this.todayElement)
651
- : (e.target === this.table);
652
- if (isLastFocusable) {
653
- e.preventDefault();
654
- if (this.isAngular) {
655
- this.inputElement.focus();
656
- }
657
- else {
658
- this.element.focus();
648
+ var popupEl = this.popupWrapper;
649
+ if (!isNullOrUndefined(popupEl)) {
650
+ var focusable = this.getPopupFocusableElements(popupEl);
651
+ var lastIndex = focusable.length - 1;
652
+ if (focusable.length > 0 && e.target === focusable[lastIndex]) {
653
+ e.preventDefault();
654
+ focusable[0].focus();
655
+ // popup stays open — no hide() call
659
656
  }
660
- this.hide();
661
657
  }
662
658
  }
663
659
  break;
664
660
  case 'shiftTab':
665
- if ((this.getModuleName() === 'datepicker' || this.getModuleName() === 'datetimepicker') && e.target === this.headerTitleElement) {
666
- e.preventDefault();
667
- if (this.isAngular) {
668
- this.inputElement.focus();
669
- }
670
- else {
671
- this.element.focus();
661
+ if (this.getModuleName() === 'datepicker' || this.getModuleName() === 'datetimepicker') {
662
+ var popupEl = this.popupWrapper;
663
+ if (!isNullOrUndefined(popupEl)) {
664
+ var focusable = this.getPopupFocusableElements(popupEl);
665
+ if (focusable.length > 0 && e.target === focusable[0]) {
666
+ e.preventDefault();
667
+ focusable[focusable.length - 1].focus();
668
+ // popup stays open — no hide() call
669
+ }
672
670
  }
673
- this.hide();
674
671
  }
675
672
  break;
676
673
  case 'escape':
@@ -680,6 +677,15 @@ var CalendarBase = /** @__PURE__ @class */ (function (_super) {
680
677
  break;
681
678
  }
682
679
  };
680
+ CalendarBase.prototype.getPopupFocusableElements = function (container) {
681
+ var selector = [
682
+ 'button:not([disabled]):not([tabindex="-1"])',
683
+ 'td[tabindex="0"]:not([aria-disabled="true"])',
684
+ '[tabindex="0"]:not([disabled])'
685
+ ].join(', ');
686
+ return Array.from(container.querySelectorAll(selector))
687
+ .filter(function (el) { return !isNullOrUndefined(el.offsetParent); });
688
+ };
683
689
  CalendarBase.prototype.keyboardNavigate = function (number, currentView, e, max, min) {
684
690
  var date = new Date(this.checkValue(this.currentDate));
685
691
  switch (currentView) {