Fix so that focus is still handled by the browser, not Elm.
This resolves the issue observed by Max and me in which focus always jumped to the first text field on the page. https://groups.google.com/forum/#!topic/elm-discuss/du9x7E9AkDE
This commit is contained in:
parent
cbf7a8633b
commit
284438d494
1 changed files with 11 additions and 6 deletions
|
@ -268,9 +268,6 @@ Elm.Native.Graphics.Input.make = function(elm) {
|
|||
field.type = model.type;
|
||||
field.placeholder = JS.fromString(model.placeHolder);
|
||||
field.value = JS.fromString(model.content.string);
|
||||
var selection = model.content.selection;
|
||||
var direction = selection.direction.ctor === 'Forward' ? 'forward' : 'backward';
|
||||
setRange(field, selection.start, selection.end, direction);
|
||||
|
||||
field.elm_signal = model.signal;
|
||||
field.elm_handler = model.handler;
|
||||
|
@ -340,6 +337,12 @@ Elm.Native.Graphics.Input.make = function(elm) {
|
|||
field.addEventListener('keypress', keyUpdate);
|
||||
field.addEventListener('input', inputUpdate);
|
||||
field.addEventListener('mousedown', mousedown);
|
||||
field.addEventListener('focus', function() {
|
||||
field.elm_hasFocus = true;
|
||||
});
|
||||
field.addEventListener('blur', function() {
|
||||
field.elm_hasFocus = false;
|
||||
});
|
||||
|
||||
return field;
|
||||
}
|
||||
|
@ -356,9 +359,11 @@ Elm.Native.Graphics.Input.make = function(elm) {
|
|||
var value = JS.fromString(newModel.content.string);
|
||||
field.value = value;
|
||||
field.elm_old_value = value;
|
||||
var selection = newModel.content.selection;
|
||||
var direction = selection.direction.ctor === 'Forward' ? 'forward' : 'backward';
|
||||
setRange(field, selection.start, selection.end, direction);
|
||||
if (field.elm_hasFocus) {
|
||||
var selection = newModel.content.selection;
|
||||
var direction = selection.direction.ctor === 'Forward' ? 'forward' : 'backward';
|
||||
setRange(field, selection.start, selection.end, direction);
|
||||
}
|
||||
}
|
||||
|
||||
function mkField(type) {
|
||||
|
|
Loading…
Reference in a new issue