-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<input> rerenders while changes affects only sibling elements #6929
Comments
You can also simply give the |
i tried your solution in codepen and still cant get it working. i tried this |
U need to have same DOM structure before your input. Look this. It can be after update your DOM before your input tag |
Actually, it is the same input element, but first remove from the document then move it to other places, for example: it first renders like <!----> // A
<input />
<!----> // B then you focus input and input some words, then virtual dom insert so, I think you could use v-show better to avoid the insertBefore move problem(remove from the document then insert before the reference node, in this case, which is comment A ). This is the default action for virtual dom of vue which doesn't replace comment node. |
|
google/incremental-dom#237 |
I have tried to fix this issue |
@Kingwl you can use |
Alternative way: Just html-layout usually has a more complex structure. What do you thing? UPD: if your case require rerender-mehanic (with v-if) |
It also seems to break (loose focus) if the spans are shown initially: https://codepen.io/janschoenherr/pen/NoJpoY?editors=1111 I would think that it doesn't need to do |
Other reproductions: https://codepen.io/adamwathan/pen/vMJrYj |
I'm using Vue 2.6.7 and this issue is still relevant, i was able to work it out by using v-show instead of v-if on a sibling, but it's still confusing why it doesn't work when v-if is used |
I found that @Focus is not reliable when using DOM manipulation, such as v-if and therefore, directives would be the best approach:
|
|
I had the problem where a I worked around this by focusing an invisible dummy |
Version
2.5.2
Reproduction link
https://codepen.io/anon/pen/OxKqbL?editors=1111
Steps to reproduce
Please open codepen example and type something into input
What is expected?
Input should not lose focus
What is actually happening?
input rerenders and loses focus
happens only if there is such conditional elements exists before and after input. Workaround is to use v-show instead of v-if in such cases.
The text was updated successfully, but these errors were encountered: