Skip to content

Custom Directive. Inserted hook. Element moved after inserted hook ended. #7761

@jacobgoh101

Description

@jacobgoh101

Version

2.5.3

Reproduction link

https://jsfiddle.net/jacobgoh101/y1L2v9d4/

Steps to reproduce

  1. Click show button

What is expected?

input#timing should be focused

What is actually happening?

input#timing was focused, but something else cause it to blur immediately


Bug 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 these

beforeUpdate

inserted <div id="app"><div><p>a</p> <input type="number" id="timing"> <p>b</p> <button type="button">show</button> <p>c</p> <!----> <p>d</p></div></div>

updated

nextTick <div id="app"><div><p>a</p> <!----> <p>b</p> <!----> <p>c</p> <input type="number" id="timing"> <p>d</p></div>  </div>

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.

See more details in this SO answer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions