From 8e4d904095c3745dee278252e0341fd9abc88a7e Mon Sep 17 00:00:00 2001 From: Sam El-Husseini <16690124+samelhusseini@users.noreply.github.com> Date: Fri, 16 Aug 2019 16:29:34 -0700 Subject: [PATCH] Listen to focus events on children and add a focused class in the dropdown (#2848) --- core/dropdowndiv.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/dropdowndiv.js b/core/dropdowndiv.js index 2808b75ed..60ccf076e 100644 --- a/core/dropdowndiv.js +++ b/core/dropdowndiv.js @@ -145,6 +145,15 @@ Blockly.DropDownDiv.createDom = function() { Blockly.DropDownDiv.DIV_.style.transition = 'transform ' + Blockly.DropDownDiv.ANIMATION_TIME + 's, ' + 'opacity ' + Blockly.DropDownDiv.ANIMATION_TIME + 's'; + + // Handle focusin/out events to add a visual indicator when + // a child is focused or blurred. + div.addEventListener('focusin', function() { + Blockly.utils.dom.addClass(div, 'focused'); + }); + div.addEventListener('focusout', function() { + Blockly.utils.dom.removeClass(div, 'focused'); + }); }; /**