From bc9c179a67eda3f1937ddcaab28a2db87f3852b9 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Sat, 2 Mar 2019 18:11:11 -0500 Subject: [PATCH] Fix search field selection upon focus --- modules/ui/search_add.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/ui/search_add.js b/modules/ui/search_add.js index 0c6e1c734..2d62e1ecc 100644 --- a/modules/ui/search_add.js +++ b/modules/ui/search_add.js @@ -51,9 +51,19 @@ export function uiSearchAdd(context) { d3_event.stopPropagation(); } }) + .on('mousedown', function() { + search.attr('clicking', true); + }) + .on('mouseup', function() { + search.attr('clicking', null); + }) .on('focus', function() { - search.node().setSelectionRange(0, search.property('value').length); - search.attr('focusing', true); + if (search.attr('clicking')) { + search.attr('focusing', true); + search.attr('clicking', null); + } else { + search.node().setSelectionRange(0, search.property('value').length); + } popover.classed('hide', false); }) .on('blur', function() { @@ -63,8 +73,6 @@ export function uiSearchAdd(context) { if (search.attr('focusing')) { search.node().setSelectionRange(0, search.property('value').length); search.attr('focusing', null); - d3_event.preventDefault(); - d3_event.stopPropagation(); } }) .on('input', function () {