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

Event type difference in onValueChange because of SyntheticEvent #805

Open
gkopowski opened this issue Oct 12, 2023 · 0 comments
Open

Event type difference in onValueChange because of SyntheticEvent #805

gkopowski opened this issue Oct 12, 2023 · 0 comments

Comments

@gkopowski
Copy link

Hi, I would like to pass a whole change event to the onChange callback when using the onValueChange prop like this:

onValueChange={({ value }, sourceInfo) => {
    onChange({
         ...sourceInfo.event,
         target: {
             ...sourceInfo.event.target,
             name: rest.name,
             value,
         },
    });
}}

but there is a difference between event that is available in sourceInfo object and the event that onChange function accepts.
My onChange function comes from Material UI input and takes ChangeEvent<HTMLInputElement>, but the sourceInfo.event type is SyntheticEvent<HTMLInputElement, Event>. Because of that there is a problem with using stopPropagation() and preventDefault() functions, because they don't exist in the SyntheticEvent. For example I can't do something like this

<MyInput
    ...
    onChange={(event) => {
        event.preventDefault(); // error
        // some logic
    }}
    />

I belive this issue can happen in many different cases, not only when integrating NumericFormat component with MUI. Is there anything I can do with that?

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

No branches or pull requests

1 participant