From e588edbccab75db422b0a8d6f60f0313f4dda53a Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 14 Nov 2019 18:33:31 +0300 Subject: [PATCH] Disable AutoFocuser on non-TV layouts --- src/components/autoFocuser.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/autoFocuser.js b/src/components/autoFocuser.js index 40b2c90703..29c5a6b5e6 100644 --- a/src/components/autoFocuser.js +++ b/src/components/autoFocuser.js @@ -1,4 +1,4 @@ -define(["focusManager"], function (focusManager) { +define(["focusManager", "layoutManager"], function (focusManager, layoutManager) { "use strict"; /** @@ -6,10 +6,21 @@ define(["focusManager"], function (focusManager) { */ var activeElement; + /** + * Returns true if AutoFocuser is enabled. + */ + function isEnabled() { + return layoutManager.tv; + }; + /** * Start AutoFocuser */ function enable() { + if (!isEnabled()) { + return; + } + window.addEventListener("focusin", function (e) { activeElement = e.target; }); @@ -21,6 +32,10 @@ define(["focusManager"], function (focusManager) { * Set focus on a suitable element, taking into account the previously selected. */ function autoFocus(container) { + if (!isEnabled()) { + return; + } + container = container || document.body; var candidates = []; @@ -67,6 +82,7 @@ define(["focusManager"], function (focusManager) { } return { + isEnabled: isEnabled, enable: enable, autoFocus: autoFocus };