-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select Geocoder text on focus. Fixes #4268. #4464
Conversation
@@ -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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of the setTimeout
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaScript cargo-culting :) This StackOverflow answer says "In Chrome the selection via .select() doesn't stick - adding a slight timeout resolves this issue.".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried the latest version of Chrome/Firefox/IE and everything worked fine without the timeout, so we can remove it to start and add it back if it's ever needed.
The general strategy for Cesium development is to target the latest version of the 5 major browsers (especially since 5 of them are evergreen) and only extra code for older browsers if its really needed and has wide enough use (and we can actually replicate the broken behavior we are fixing first).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried on the latest version of Safari (10.0 (12602.1.50.0.10)), and it seems that setTimeout
is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, thanks for checking. Can you add a comment to the code indicating the setTimeout is needed for Safari, this way someone doesn't accidentally remove it in the future. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Thanks @twpayne! The functionality is great. My only other comment is that we should call |
Done. |
@@ -164,6 +175,7 @@ cesiumSvgPath: { path: isSearchInProgress ? _stopSearchPath : _startSearchPath, | |||
|
|||
knockout.cleanNode(this._form); | |||
this._container.removeChild(this._form); | |||
this._textBox.removeEventListener(this._onTextBoxFocus, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be this._textBox.removeEventListener('focus', this._onTextBoxFocus, false);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh! Good catch. Sorry. Fixed.
Perfect, thanks @twpayne! |
I'll update |
cc @hpinkos
Slightly different code might be required for older iOS devices, see discussion on StackOverflow.