Ensure select_on_focus handlers are not called recursively

This fixes #1696.

(imported from commit 4d7ba3a1e34aa48d2675178913de30d081653762)
This commit is contained in:
Zev Benjamin 2013-09-17 19:45:18 -04:00
parent 4af8eaaa7a
commit 7c74983370
1 changed files with 9 additions and 0 deletions

View File

@ -162,10 +162,19 @@ function handle_keyup(e) {
// http://stackoverflow.com/questions/3380458/looking-for-a-better-workaround-to-chrome-select-on-focus-bug
function select_on_focus(field_id) {
// A select event appears to trigger a focus event under certain
// conditions in Chrome so we need to protect against infinite
// recursion.
var in_handler = false;
$("#" + field_id).focus(function (e) {
if (in_handler) {
return;
}
in_handler = true;
$("#" + field_id).select().one('mouseup', function (e) {
e.preventDefault();
});
in_handler = false;
});
}