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 #1388 - Respect latest field's initial value (esp when its forcefully recreated) #1389

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nvshah
Copy link

@nvshah nvshah commented May 4, 2024

TASK #1388

Connection with issue(s)

Solution description

Always respect latest field's initial value rather than assigning old field's value (if present)

Screenshots or Videos

To Do

  • Read contributing guide
  • Check the original issue to confirm it is fully satisfied
  • Add solution description to help guide reviewers
  • Add unit test to verify new or fixed behaviour
  • If apply, add documentation to code properties and package readme

@deandreamatias
Copy link
Collaborator

Hi! Thanks for contribution!

I updated the build to run with flutter 3.22.
This changes do not pass on test, so is a breaking change compared with current behavior.

Take a look if can change the solution or have some way to pass tests without delete them

@kris175
Copy link

kris175 commented May 31, 2024

Hi, I doubt whether this is the actual root cause or not.

I was able to temporarily fix this issue where the initial value is not being assigned upon reset by reverting to the version 7 which has the same code that is being replaced in this PR, but not in shorthand form.

if (oldField != null) {
      // ignore: invalid_use_of_protected_member
      field.setValue(oldField.value, populateForm: false);
    } else {
      // ignore: invalid_use_of_protected_member
      field.setValue(
        _instantValue[name] ??= field.initialValue,
        populateForm: false,
      );
    }

Therefore it leads me to think it's some other change which is causing this issue and not because of this specific piece of code being changed in the PR.

I will try to compare changes and update if I get time.

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.

None yet

3 participants