From 397c73b3bb9d814b3fde4ef9b3d685925137f141 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Tue, 19 Nov 2019 22:31:49 +0000 Subject: [PATCH] Bug 1597707 - Do not dispatch SELECT_ALL selection action if the input is empty or all the text is already selected. r=esawin Do not dispatch SELECT_ALL selection action if the input is empty or all the text is already selected. Differential Revision: https://phabricator.services.mozilla.com/D53828 --HG-- extra : moz-landing-system : lando --- .../geckoview/GeckoViewSelectionActionChild.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mobile/android/chrome/geckoview/GeckoViewSelectionActionChild.js b/mobile/android/chrome/geckoview/GeckoViewSelectionActionChild.js index e6ab77cae19f..37a5f65cc955 100644 --- a/mobile/android/chrome/geckoview/GeckoViewSelectionActionChild.js +++ b/mobile/android/chrome/geckoview/GeckoViewSelectionActionChild.js @@ -70,7 +70,18 @@ class GeckoViewSelectionActionChild extends GeckoViewChildModule { }, { id: "org.mozilla.geckoview.SELECT_ALL", - predicate: e => e.reason !== "longpressonemptycontent", + predicate: e => { + if (e.reason === "longpressonemptycontent") { + return false; + } + if (e.target && e.target.activeElement) { + const value = e.target.activeElement.value; + // Do not show SELECT_ALL if the input is empty + // or all the input text is already selected. + return value !== "" && value !== e.selectedTextContent; + } + return true; + }, perform: e => docShell.doCommand("cmd_selectAll"), }, ];