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

Different controller behaviour in v7.41.0 #9621

Closed
bluebill1049 opened this issue Dec 19, 2022 · 2 comments
Closed

Different controller behaviour in v7.41.0 #9621

bluebill1049 opened this issue Dec 19, 2022 · 2 comments
Labels
regression Regression with code change

Comments

@bluebill1049
Copy link
Member

  Hi guys,

i just stumbled across some weird behaviour with the new version v7.41.0.
It seems like the defaultValue of the controller can no longer be accessed with the field.value property.

in my project, i have a function, which renders my form fields depending on the settings i get from the database:

const ReturnAndRenderSettings = (): ReactNode[] => {
        return availableSettings.map((s) => {
            return (
                <div className={"field"}>
                    <Controller name={s.Name} control={settingsControl}
                                defaultValue={userSettings.find(
                                    us => us.SettingId == s.ID)?.IsEnabled ?? false}
                                render={({field, fieldState}) => (

                                    <Setting name={s.Name}
                                             disabled={inSubmit}
                                             defaultValue={field.value}
                                             onChange={setSettingsValue}/>
                                )}/>
                </div>
            );
        })
    };

As you can see here, i´m searching for the matching setting which i get from the server, and then i get the actual value from the IsEnabled property. As fallback i´m using false.

This code worked fine till v7.41.0 and the result looked like this:
Screenshot_1

However with the newst version field.value is always undefined.
The result, as expected, looks like this:
Screenshot_2

It seems like in version <7.41.0 field.value was identical with the controller default value, and since 7.41.0 this is not the case anymore.

I´ve read about the new values and defaultValues things in the new versions but found no connection to the controller, so this makes me wonder if i´m missing something here🤔

Originally posted by @manuelpoelzl in #9613

@bluebill1049 bluebill1049 added status: under investigation aware of this issue and pending for investigation regression Regression with code change and removed status: under investigation aware of this issue and pending for investigation labels Dec 19, 2022
@sofsscosta
Copy link

Second this problem, I have also just encountered this in my repo. Also looking for a solution here

@Moshyfawn
Copy link
Member

This fix is in and is going to be included in the next release. No ETA

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
regression Regression with code change
Projects
None yet
Development

No branches or pull requests

3 participants