Skip to content

Commit

Permalink
focus nodes on the next tick
Browse files Browse the repository at this point in the history
when the hook is run, the node may not be in the document yet
  • Loading branch information
neonstalwart committed May 19, 2014
1 parent aa94583 commit 6305d02
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/todomvc/lib/do-mutable-focus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var document = require("global/document")
var nextTick = require('next-tick')

module.exports = MutableFocusHook

Expand All @@ -9,7 +10,9 @@ function MutableFocusHook() {
}

MutableFocusHook.prototype.hook = function (node, property) {
if (document.activeElement !== node) {
node.focus();
}
nextTick(function () {
if (document.activeElement !== node) {
node.focus();
}
})
}

0 comments on commit 6305d02

Please sign in to comment.