nextTick is unreliable #4580
Unanswered
ludwig-gramberg
asked this question in
1. Help
Replies: 1 comment 9 replies
-
I think this is specifically an issue with scroll into view. That the Dom is updated (like you did get the item when querying for it), but since the browser has not fully painted it doesn't know what exactly is in view or not. Without just making nexttick arbitrarily slower, there isn't much that can be done. You can just nest nexttick calls. await this.$nextTick(this.$nextTick) To wait for another frame. The updates to the DOM are always available after |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm breaking my brain trying to have reliable scroll behavior after alpine is finished with applying changes.
I was expecting that $nextTick fires when all changes are applied to the DOM. But it regularly does so before (or so it seams).
In my example a
<ul>
is made visible withx-show
once it has elements. The following are screenshots of the Chrome console when the mutations are observed and then the nextTick callback fires.The result is that a scrollIntoView does not work because the element is not actually visible yet.
Single Mutation observed after $nextTick:
All mutations observed before $nextTick:
Video of different behaviors (only to be observed after a fresh page load).
Sample-Code:
https://awesomealpine.com/play?share=m2SSM1_7XKEt
In Case the Sample is no longer online:
JS:
HTML:
Beta Was this translation helpful? Give feedback.
All reactions