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

Autoform onChangeModel no longer working? #1207

Closed
mikkelking opened this issue Dec 28, 2022 · 6 comments
Closed

Autoform onChangeModel no longer working? #1207

mikkelking opened this issue Dec 28, 2022 · 6 comments
Assignees
Labels
Type: Question Questions and other discussions

Comments

@mikkelking
Copy link

Uniforms 3.10.2

The property onChangeModel is no longer called. There is reference made to it in #1083 which suggests that the property is somehow obsolete due to changes in the typing. The code omits the property, but it would still call it if present.

How do I get around this (short of reverting to an older version?) Is there some way to force the prop onto the object? (I am not using typescript)

@radekmie radekmie self-assigned this Dec 29, 2022
@radekmie radekmie added the Type: Question Questions and other discussions label Dec 29, 2022
@github-project-automation github-project-automation bot moved this to Needs triage in Open Source Dec 29, 2022
@radekmie radekmie moved this from Needs triage to In progress in Open Source Dec 29, 2022
@radekmie
Copy link
Contributor

Hi @mikkelking. Could you maybe provide a reproduction? This prop is not deprecated and #1083 only mentions the incorrect typings, which should not be a problem if you're not using TypeScript.

@mikkelking
Copy link
Author

@radekmie It's in a private repo - can I add you as a contributor so you can look at it?

@radekmie
Copy link
Contributor

I'd rather not, really. Use our Codesandbox template and see if you can reproduce it there first.

@mikkelking
Copy link
Author

Of course the sandbox works perfectly. The problem is that I am building the schema dynamically from a definition file, and reproducing the problem isn't easy without pretty much moving all of my code into the sandbox

I have the same problem with 3.10.1, 3.10.2 and 4.0 Alpha. It works ok in 3.10.0
I pulled up a github comparison here https://github.com/vazco/uniforms/compare/74cd15102ff1684934115a9a998a2e0862b6fdc8..37fa8c1e482cb9c3e8bd6e6395258634366b5d8a
but I can't see any changes that would impact the calling of the onChangeModel callback.

But looking at

// @ts-expect-error: Mixin class problem.

I see this function, which appears to remove the onChangeModel function from the props

    getNativeFormProps() {
      const props = super.getNativeFormProps();
      return omit(props, ['onChangeModel']) as typeof props;
    }

I don't know when that is called, but might this be the problem?

@radekmie
Copy link
Contributor

radekmie commented Jan 2, 2023

Nope, the code you listed is correct - we don't want onChangeModel to be passed down to the native <form> element. The problem originates in #1170, as the onChangeModel is called in the callback of a setState call. But that means, your code relied on a bug then. Please check if the component is not unmounted too soon - it looks like it.

@radekmie
Copy link
Contributor

I'll close this one for now, but as soon as you'd have a reproduction, please post it here or in a new issue.

@github-project-automation github-project-automation bot moved this from In progress to Closed in Open Source Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Questions and other discussions
Projects
Archived in project
Development

No branches or pull requests

2 participants