From b4368224986fd7229f5b31b4e3fa5c1334cc0cea Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Mon, 5 Mar 2018 17:18:03 -0800 Subject: [PATCH] Changing clear element atom to be W3C compliant --- javascript/atoms/action.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/javascript/atoms/action.js b/javascript/atoms/action.js index b93d444448058..7c3767d1e27d4 100644 --- a/javascript/atoms/action.js +++ b/javascript/atoms/action.js @@ -87,21 +87,25 @@ bot.action.clear = function(element) { 'Element must be user-editable in order to clear it.'); } - bot.action.LegacyDevice_.focusOnElement(element); if (element.value) { + bot.action.LegacyDevice_.focusOnElement(element); element.value = ''; bot.events.fire(element, bot.events.EventType.CHANGE); + bot.events.fire(element, bot.events.EventType.BLUR); + bot.action.LegacyDevice_.focusOnElement(document.body); } else if (bot.dom.isElement(element, goog.dom.TagName.INPUT) && (element.getAttribute('type') && element.getAttribute('type').toLowerCase() == "number")) { // number input fields that have invalid inputs // report their value as empty string with no way to tell if there is a // current value or not + bot.action.LegacyDevice_.focusOnElement(element); element.value = ''; } if (bot.dom.isContentEditable(element)) { // A single space is required, if you put empty string here you'll not be // able to interact with this element anymore in Firefox. + bot.action.LegacyDevice_.focusOnElement(element); element.innerHTML = ' '; // contentEditable does not generate onchange event. }