Skip to content
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

Undoing remove children change children orders #7856

Closed
chuckn0rris opened this issue Nov 13, 2023 · 0 comments
Closed

Undoing remove children change children orders #7856

chuckn0rris opened this issue Nov 13, 2023 · 0 comments
Assignees
Labels
bug Something isn't working forum Issues from forum OEM OEM customer premium resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@chuckn0rris
Copy link

Forum post

task-order-bug.mov

Hi Bryntum support,

I found an unexpected behavior when I undo removing children.
Sometimes, undoing removing children can't keep children orders.
It can be reproduced at https://bryntum.com/products/gantt/examples/undoredo/.

I've investigated why it happens. Maybe I found a bug in the RemoveChildAction.undo function.
In the code below, childModels.sort will fail because context.get returns an object, not parentIndex.
Shouldn't it be like context.get(lhs).parentIndex?
If it's a bug, please fix it in the future.

    undo() {
        const { parentModel, context, childModels } = this;

    // Let's sort models by parent index such that models with lesser index
    // were inserted back first, thus making valid parent index of models following.

    childModels.sort((lhs, rhs) => {
        const
            lhsIndex = context.get(lhs),
            rhsIndex = context.get(rhs);

        return (lhsIndex - rhsIndex);
    });

    // Now let's re-insert records back to where they were
    childModels.forEach(m => {
        const ctx = context.get(m);

        parentModel.insertChild(m, ctx.parentIndex, undefined, { orderedParentIndex : ctx.orderedParentIndex });
    });
}

@chuckn0rris chuckn0rris added bug Something isn't working premium forum Issues from forum OEM OEM customer labels Nov 13, 2023
@canonic-epicure canonic-epicure self-assigned this Jan 18, 2024
@canonic-epicure canonic-epicure added in progress ready for review Issue is fixed, the pull request is being reviewed and removed in progress labels Jan 18, 2024
@isglass isglass added resolved Fixed but not yet released (available in the nightly builds) and removed ready for review Issue is fixed, the pull request is being reviewed labels Jan 18, 2024
@isglass isglass added this to the 5.6.6 milestone Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum OEM OEM customer premium resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

3 participants