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

Dependency Store beforeAdd Event giving error if it returns false #8322

Closed
kronaemmanuel opened this issue Jan 22, 2024 · 1 comment
Closed
Assignees
Labels
bug Something isn't working forum Issues from forum resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@kronaemmanuel
Copy link

Steps to repro:
In our Gantt/examples/frameworks/react/typescript/basic, try this code in App.tsx:

const App: FunctionComponent = () => {
    const ganttRef = useRef<BryntumGantt>(null);

    useEffect(() => {
        const ganttInstance = ganttRef.current?.instance;
        if (ganttInstance) {
            const handleBeforeAdd = () => false;
            // @ts-ignore
            ganttInstance.dependencyStore.on('beforeAdd', handleBeforeAdd);
        }
    }, [ganttRef]);

    return (
        <Fragment>
            {/* BryntumDemoHeader component is used for Bryntum example styling only and can be removed */}
            <BryntumDemoHeader/>
            <BryntumGantt ref={ganttRef} {...ganttConfig} />
        </Fragment>
    );
};

Forum post

Hi All,

I am facing an issue in the dependency store. I want to add additional logic before creating new dependencies between tasks for that I want to use beforeAdd event of the Dependency store as it says in the documentation that it is a preventable event and can be prevented dependencies by returning false

Screenshot 2024-01-22 at 5.43.20 PM.png

But when I return false from that function it gives error:
Screenshot 2024-01-22 at 5.45.27 PM.png

The code I am using for now:

ganttInstance?.dependencyStore?.on({
            add: handleAddDependency,
            remove: handleRemoveDependency,
            beforeAdd: () => {
                return false;
            },
        });

I am also attaching a runnable test case with steps to reproduce:
Add any dependency between any task.
See error in console.
Screenshot 2024-01-22 at 5.43.20 PM.png
Screenshot 2024-01-22 at 5.45.27 PM.png

@kronaemmanuel kronaemmanuel added bug Something isn't working forum Issues from forum labels Jan 22, 2024
@ghulamghousdev
Copy link
Member

It is also reproducible in basic gantt demo https://bryntum.com/products/gantt/examples/basic/:

Screen.Recording.2024-01-22.at.7.33.15.PM.mov

@ghulamghousdev ghulamghousdev self-assigned this Jan 22, 2024
@ghulamghousdev ghulamghousdev changed the title [REACT] Dependency Store beforeAdd Event giving error if it returns false Dependency Store beforeAdd Event giving error if it returns false Jan 22, 2024
@ghulamghousdev ghulamghousdev added ready for review Issue is fixed, the pull request is being reviewed and removed in progress labels Jan 22, 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 25, 2024
@isglass isglass added this to the 5.6.6 milestone Jan 25, 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 resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

3 participants