You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in inserted hook, input#timing is between <p>a</p> and <p>b</p>. But in nextTick callback, input#timing has been moved to between <p>c</p> and <p>d</p>, for no particular reason. This caused the element to blur out.
The text was updated successfully, but these errors were encountered:
jacobgoh101
changed the title
Custom Directive. Inserted hook. Element is moved after inserted hook ended.
Custom Directive. Inserted hook. Element moved after inserted hook ended.
Mar 7, 2018
The element gets moved more than necessary causing it to blur out, but I wonder if inserted could be called at the end rather than exactly when inserted...
As a valid workaround, you can do Vue.nextTick(() => el.focus()) to focus the element
This is because in your case the same input element was reused, and the inserted hook fired before it was moved.
Technically, the diffing could probably be improved since there no need to really move it, but this cannot be guaranteed in all cases when no keys are provided, so it's safer to always do focus in a nextTick.
Version
2.5.3
Reproduction link
https://jsfiddle.net/jacobgoh101/y1L2v9d4/
Steps to reproduce
show
buttonWhat is expected?
input#timing
should be focusedWhat is actually happening?
input#timing
was focused, but something else cause it to blur immediatelyBug discovered from this Stack Overflow question together with acdcjunior.
from this example https://jsfiddle.net/acdcjunior/srfse9oe/1/ , after clicking on
show
button, the console log thesein inserted hook,
input#timing
is between<p>a</p>
and<p>b</p>
. But innextTick
callback,input#timing
has been moved to between<p>c</p>
and<p>d</p>
, for no particular reason. This caused the element to blur out.See more details in this SO answer
The text was updated successfully, but these errors were encountered: