角度材质(日期选择器)在任何基于键盘的操作后都聚焦在主体上

angular material (datepicker) focus is on body after any keyboard based operation

本文关键字:操作 主体 聚焦 键盘 任何基 日期 选择器 于键盘      更新时间:2023-09-26

似乎使用日期选择器的每个操作都不会将焦点返回到日期选择器输入或按钮,因此选项卡索引返回到第一个元素。

您可以通过官方演示为例:https://material.angularjs.org/latest/demo/datepicker

查看源代码和调试 - 似乎焦点操作是在相关元素上触发的,但即便如此 - 焦点更改为文档正文。

 /** Close the floating calendar pane. */
  DatePickerCtrl.prototype.closeCalendarPane = function() {
    if (this.isCalendarOpen) {
      var self = this;
      self.calendarPaneOpenedFrom.focus();
      self.calendarPaneOpenedFrom = null;
      if (self.openOnFocus) {
        // Ensures that all focus events have fired before detaching
        // the calendar. Prevents the calendar from reopening immediately
        // in IE when md-open-on-focus is set. Also it needs to trigger
        // a digest, in order to prevent issues where the calendar wasn't
        // showing up on the next open.
        this.$mdUtil.nextTick(detach);
      } else {
        detach();
      }
    }
    function detach() {
      self.detachCalendarPane();
      self.isCalendarOpen = false;
      self.ngModelCtrl.$setTouched();
      self.documentElement.off('click touchstart', self.bodyClickHandler);
      window.removeEventListener('resize', self.windowResizeHandler);
    }
  };

10 倍埃拉德。

日期选取器焦点问题中存在一个错误,因为内部的 SVG 元素没有传播焦点事件。

由克里斯贝托解决。

编号 : https://github.com/crisbeto/material/commit/e8d4ad217dd2ad5a8e8875f9bdc1269679667e3b