-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
FutureIndex inaccurate (always 0) on first interaction #603
Comments
Hello, |
@David-Desmaisons I think when you release the drag the element will be inserted to wherever Sortable thinks it should belong: definitely not back to position 0. Note that the behavior is correct for all subsequent drag and drop interaction, just not the first time. Try dragging the first item to the end of the list. It indicates that the When you repeat that action again (dragging first item to original position), and then trying to drag it to the end of the list, now |
@David-Desmaisons If you look at your fiddle screen recording, you've already sorted the list before (since "Dolor" is not the default first item in the original order). As I have mentioned, this is only reproducible on the first interaction with the list: since you have interacted with the list prior to the recording, the bug cannot be reproduced. If you refresh the page (or rerun the fiddle), and start dragging the first item ("Lorem"), you will be able to reproduce the problem. Looking into the actual code itself, it seems like the error might be coming from this line: https://github.com/SortableJS/Vue.Draggable/blob/master/src/vuedraggable.js#L426
I have a feeling that |
@terrymun understood I am able to reproduce now. |
Updated fiddle for reproduction: Still reproductible with version 2.21.0 and sortable 1.19.0 |
Corrected in version 2.23.0 |
@David-Desmaisons Thanks for looking into the issue and fixing it 💯 |
hey @David-Desmaisons I'm confused as to why this was closed last year. I'm still experiencing this issue using |
I have the same problem, the futureIndex is always 0. I am using Vuedragable v2.24.3 and SortableJS v1.10.2 |
In case someone is having trouble with this, I managed to circumvent it with this hack: if (this.draggableListItems.length > 1)
this.$refs['draggable-list-component'].updatePosition(0, 1);
this.$refs['draggable-list-component'].updatePosition(1, 0);
} Obviously, it should be called after the list has been initialized but before the user has a chance to interact with the list, e.g. in the mounted-hook. |
Hey @sam-19, does this really fix your problem? I can still reproduce this bug in my Vue project using vuedraggable v2.24.3. I am trying really hard updating nested-vuex-data after the view is mounted to avoid the "first-interaction-bug", but it still appears. Can't just anyone merge the current Sortable.js version into VueDraggable? The bug should have been fixed there, why not in the Vue version? |
@hovsepian your solution actually worked for me, man thank you!! :-) |
Odd behaviour. Mine is still doing this even tho I already wrapped my child component in a div with v-for and unique keys. @sam_19 your solution actually helped me. =) solved my problem. |
@milenarmp which version of the library and of Vue do you use? |
Hello, I'm sorry to re-open this discussion, but the problem is still there for me. The template (regionStopList is a cloneDeep of region.regionStopList) : <region-stop-component ` Any help would be welcome :) |
@sam-19 thanks. The workaround worked very well! |
When dragging and dropping in
<draggable>
, it appears that the first time the list is being interacted with always reports thefutureIndex
as being0
:Proof-of-concept demo of the problem
https://jsfiddle.net/teddyrised/64753ck1/
Description of the issue
e.draggableContext.futureIndex
is always 0 regardless of the future positiononEnd()
event reports the correct old and new indecesfutureIndex
is reported correctlyExpected behavior
On the first drag interaction, the
futureIndex
should report an accurate expected/future index instead of0
.The text was updated successfully, but these errors were encountered: