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
This commit is contained in:
Imanol Fernandez 2019-11-19 22:31:49 +00:00
parent af9edac0e5
commit 397c73b3bb

View File

@ -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"),
},
];