Skip to content

Commit

Permalink
Merge pull request #4464 from twpayne/geocoder-highlight-on-click
Browse files Browse the repository at this point in the history
Select Geocoder text on focus. Fixes #4268.
  • Loading branch information
Hannah authored Oct 20, 2016
2 parents 37f9e7d + f91b8a7 commit 460357c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/Widgets/Geocoder/Geocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,18 @@ value: searchText,\
valueUpdate: "afterkeydown",\
disable: isSearchInProgress,\
css: { "cesium-geocoder-input-wide" : keepExpanded || searchText.length > 0 }');

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';
Expand Down Expand Up @@ -164,6 +175,7 @@ cesiumSvgPath: { path: isSearchInProgress ? _stopSearchPath : _startSearchPath,

knockout.cleanNode(this._form);
this._container.removeChild(this._form);
this._textBox.removeEventListener('focus', this._onTextBoxFocus, false);

return destroyObject(this);
};
Expand Down

0 comments on commit 460357c

Please sign in to comment.