From 259bac802ed887c8b1a5f81dc7931c0642bcb8c3 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 19 Oct 2016 17:16:56 -0400 Subject: [PATCH 1/4] Select Geocoder text on focus. Fixes #4268. --- Source/Widgets/Geocoder/Geocoder.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Widgets/Geocoder/Geocoder.js b/Source/Widgets/Geocoder/Geocoder.js index d697bbb01aa3..3e2754ebff81 100644 --- a/Source/Widgets/Geocoder/Geocoder.js +++ b/Source/Widgets/Geocoder/Geocoder.js @@ -70,6 +70,11 @@ value: searchText,\ valueUpdate: "afterkeydown",\ disable: isSearchInProgress,\ css: { "cesium-geocoder-input-wide" : keepExpanded || searchText.length > 0 }'); + textBox.addEventListener('focus', function() { + setTimeout(function() { + textBox.select(); + }, 0); + }); form.appendChild(textBox); var searchButton = document.createElement('span'); From ad5d8e036ec965d14d679dfd2d2007880569188c Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 19 Oct 2016 21:41:44 -0400 Subject: [PATCH 2/4] Add comment about select Safari hack. --- Source/Widgets/Geocoder/Geocoder.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Widgets/Geocoder/Geocoder.js b/Source/Widgets/Geocoder/Geocoder.js index 3e2754ebff81..0afcf6486a7a 100644 --- a/Source/Widgets/Geocoder/Geocoder.js +++ b/Source/Widgets/Geocoder/Geocoder.js @@ -71,6 +71,8 @@ valueUpdate: "afterkeydown",\ disable: isSearchInProgress,\ css: { "cesium-geocoder-input-wide" : keepExpanded || searchText.length > 0 }'); textBox.addEventListener('focus', function() { + // as of 2016-10-19, setTimeout is required to ensure that the + // text is focused on Safari 10 setTimeout(function() { textBox.select(); }, 0); From 3bec4934e17e3ee2b0b4a1e815129c29ce676f03 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 20 Oct 2016 09:47:43 -0400 Subject: [PATCH 3/4] Remove focus event listener on Geocoder destroy. --- Source/Widgets/Geocoder/Geocoder.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Widgets/Geocoder/Geocoder.js b/Source/Widgets/Geocoder/Geocoder.js index 0afcf6486a7a..4fd8e239d008 100644 --- a/Source/Widgets/Geocoder/Geocoder.js +++ b/Source/Widgets/Geocoder/Geocoder.js @@ -70,14 +70,18 @@ value: searchText,\ valueUpdate: "afterkeydown",\ disable: isSearchInProgress,\ css: { "cesium-geocoder-input-wide" : keepExpanded || searchText.length > 0 }'); - textBox.addEventListener('focus', function() { + + this._onTextBoxFocus = function() { // as of 2016-10-19, setTimeout is required to ensure that the // text is focused on Safari 10 setTimeout(function() { textBox.select(); }, 0); - }); + }; + + textBox.addEventListener('focus', this._onTextBoxFocus, false); form.appendChild(textBox); + this._textBox = textBox; var searchButton = document.createElement('span'); searchButton.className = 'cesium-geocoder-searchButton'; @@ -171,6 +175,7 @@ cesiumSvgPath: { path: isSearchInProgress ? _stopSearchPath : _startSearchPath, knockout.cleanNode(this._form); this._container.removeChild(this._form); + this._textBox.removeEventListener(this._onTextBoxFocus, false); return destroyObject(this); }; From f91b8a7b770ee3fdca19dfc471c84f563bc85c28 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 20 Oct 2016 10:00:06 -0400 Subject: [PATCH 4/4] Add missed event type. --- Source/Widgets/Geocoder/Geocoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Widgets/Geocoder/Geocoder.js b/Source/Widgets/Geocoder/Geocoder.js index 4fd8e239d008..62caa68a9a5d 100644 --- a/Source/Widgets/Geocoder/Geocoder.js +++ b/Source/Widgets/Geocoder/Geocoder.js @@ -175,7 +175,7 @@ cesiumSvgPath: { path: isSearchInProgress ? _stopSearchPath : _startSearchPath, knockout.cleanNode(this._form); this._container.removeChild(this._form); - this._textBox.removeEventListener(this._onTextBoxFocus, false); + this._textBox.removeEventListener('focus', this._onTextBoxFocus, false); return destroyObject(this); };