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

Fix #3107: ImperativeHandle put props first #3108

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

melloware
Copy link
Member

###Defect Fixes
Fix #3107: ImperativeHandle put props first

So the properties don't clobber methods like filter

@mertsincan
Copy link
Member

mertsincan commented Jul 26, 2022

Maybe, it can be like;

this.dtRef.current.props.first  instead of this.dtRef.current.first

Exp;
const datatableInstance = this.dfRef.current;

datatableInstance.props.first
datatableInstance.resetFilter
...

WDYT?

@melloware
Copy link
Member Author

@mertsincan that is what I wanted to do but it wouldn't let me do this...

    React.useImperativeHandle(ref, () => ({
        props: ...props,
        getElement: () => elementRef.current
    }));

The only thing i could see doing was ...

    React.useImperativeHandle(ref, () => ({
        getProps: () =>  ...props,
        getElement: () => elementRef.current
    }));

But not sure I liked that either. Any help here would be appreciated!

@mertsincan
Copy link
Member

Could you please try;

React.useImperativeHandle(ref, () => ({
        props,
        getElement: () => elementRef.current
}));

What error do you get when you use it?

@melloware
Copy link
Member Author

Let me try...

@melloware
Copy link
Member Author

DUH! that works great and is exactly what we want. I just updated the PR.

@melloware melloware merged commit 3f458d5 into primefaces:master Jul 26, 2022
@melloware melloware deleted the PR3107 branch July 26, 2022 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tree: Custom filter broken due to overwritten props in useImperativeHandle hook.
2 participants