crysalead-js / dom-layer

Virtual DOM implementation.
MIT License
30 stars 1 forks source link

Focus lost #22

Closed ghost closed 9 years ago

ghost commented 9 years ago

Let say you have created a virtual DOM tree, and want to trigger a event on a particular node in the tree.

How you do it?

Example "change" should be "triggered" each time you e.g. click / change it. And I can't find any use of document.activeElement, so the focus will be lost if you have 3 select and jumping from one to one?

jails commented 9 years ago

Not sure this question is related to dom-layer. Just use vanilla JS to programmatically trigger your event on you DOM element, the event manager will forwared it up to the virtual node events available event handler. Otherwise I didn't understand what you want to do with document.activeElement

ghost commented 9 years ago

If you check out this function in REACT getActiveElement().

Quote from one use case: "If any selection information was potentially lost, restore it. This is useful when performing operations that could remove dom nodes and place them back in, resulting in focus being lost. " Maybe you can get ideas from this source? https://github.com/jhudson8/react-events/blob/master/react-events.js

jails commented 9 years ago

You are talking about the focus lost issue ?

ghost commented 9 years ago

yes, focus and state lost issues

jails commented 9 years ago

Sates issue shouldn't occurs if you are using the key attribute correclty (like in React). And when inputs are moved around they will lost their focus but I didn't managed it right now.

jails commented 9 years ago

Should be fixed in https://github.com/crysalead-js/dom-layer/commit/f4087859991ec5b9e65d029d44aa97cddf59af01

https://jsfiddle.net/qgm0uftb/