Completely updated React, fixed #11, (hopefully)
This commit is contained in:
29
goTorrentWebUI/node_modules/material-ui/utils/keyboardFocus.js
generated
vendored
29
goTorrentWebUI/node_modules/material-ui/utils/keyboardFocus.js
generated
vendored
@@ -19,16 +19,15 @@ var _contains = require('dom-helpers/query/contains');
|
||||
|
||||
var _contains2 = _interopRequireDefault(_contains);
|
||||
|
||||
var _addEventListener = require('../utils/addEventListener');
|
||||
var _ownerDocument = require('dom-helpers/ownerDocument');
|
||||
|
||||
var _addEventListener2 = _interopRequireDefault(_addEventListener);
|
||||
var _ownerDocument2 = _interopRequireDefault(_ownerDocument);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// weak
|
||||
|
||||
var internal = {
|
||||
listening: false,
|
||||
focusKeyPressed: false
|
||||
};
|
||||
|
||||
@@ -47,7 +46,9 @@ function detectKeyboardFocus(instance, element, callback) {
|
||||
process.env.NODE_ENV !== "production" ? (0, _warning2.default)(instance.keyboardFocusMaxCheckTimes, 'Material-UI: missing instance.keyboardFocusMaxCheckTimes') : void 0;
|
||||
|
||||
instance.keyboardFocusTimeout = setTimeout(function () {
|
||||
if (focusKeyPressed() && (document.activeElement === element || (0, _contains2.default)(element, document.activeElement))) {
|
||||
var doc = (0, _ownerDocument2.default)(element);
|
||||
|
||||
if (focusKeyPressed() && (doc.activeElement === element || (0, _contains2.default)(element, doc.activeElement))) {
|
||||
callback();
|
||||
} else if (attempt < instance.keyboardFocusMaxCheckTimes) {
|
||||
detectKeyboardFocus(instance, element, callback, attempt + 1);
|
||||
@@ -61,15 +62,15 @@ function isFocusKey(event) {
|
||||
return FOCUS_KEYS.indexOf((0, _keycode2.default)(event)) !== -1;
|
||||
}
|
||||
|
||||
function listenForFocusKeys() {
|
||||
// It's a singleton, we only need to listen once.
|
||||
// Also, this logic is client side only, we don't need a teardown.
|
||||
if (!internal.listening) {
|
||||
(0, _addEventListener2.default)(window, 'keyup', function (event) {
|
||||
if (isFocusKey(event)) {
|
||||
internal.focusKeyPressed = true;
|
||||
}
|
||||
});
|
||||
internal.listening = true;
|
||||
var handleKeyUpEvent = function handleKeyUpEvent(event) {
|
||||
if (isFocusKey(event)) {
|
||||
internal.focusKeyPressed = true;
|
||||
}
|
||||
};
|
||||
|
||||
function listenForFocusKeys(win) {
|
||||
// The event listener will only be added once per window.
|
||||
// Duplicate event listeners will be ignored by addEventListener.
|
||||
// Also, this logic is client side only, we don't need a teardown.
|
||||
win.addEventListener('keyup', handleKeyUpEvent);
|
||||
}
|
Reference in New Issue
Block a user