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

Improve focus and scroll #1223

Merged
merged 7 commits into from Apr 22, 2023
Merged

Improve focus and scroll #1223

merged 7 commits into from Apr 22, 2023

Conversation

deandreamatias
Copy link
Collaborator

@deandreamatias deandreamatias commented Apr 21, 2023

Connection with issue(s)

Close #955
Close #1049

Connected to flutter-form-builder-ecosystem/form_builder_extra_fields#10

Solution description

BREAKING CHANGE

This PR improve how handle and use focus and scroll when validate and invalidate fields.
Now, we have two news behaviors when validate or invalidate a field or form:

  • By default, the first or single field with validation error, will be focused
  • Only if autoScrollWhenFocusOnInvalid will be true, automatic scroll will happens and will show the first or single error. By default, this behavior is deactivate

Note: If a invalid field is from type TextField and will focused, the form will auto scroll to show this invalid field.
In this case, the automatic scroll happens because is a behavior inside the framework, not because autoScrollWhenFocusOnInvalid is true.

  • Remove property shouldRequestFocus for each form field
  • Remove property autoFocusOnValidationFailure on FormBuilder
  • Add focusOnInvalid and autoScrollWhenFocusOnInvalid to validate and saveAndValidate methods from FormBuilderState
  • Add focusOnInvalid and autoScrollWhenFocusOnInvalid to validate method from FormBuilderFieldState
  • Add shouldFocus and shouldAutoScrollWhenFocus to invalidate method from FormBuilderFieldState

In other hand, remove and add some deprecated fields and update example config.

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

@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Merging #1223 (764e91a) into main (c88535d) will increase coverage by 0.64%.
The diff coverage is 67.85%.

@@            Coverage Diff             @@
##             main    #1223      +/-   ##
==========================================
+ Coverage   83.66%   84.30%   +0.64%     
==========================================
  Files          19       19              
  Lines         710      701       -9     
==========================================
- Hits          594      591       -3     
+ Misses        116      110       -6     
Impacted Files Coverage Δ
lib/src/fields/form_builder_checkbox.dart 100.00% <ø> (+7.69%) ⬆️
lib/src/fields/form_builder_checkbox_group.dart 92.30% <ø> (+6.59%) ⬆️
lib/src/fields/form_builder_choice_chips.dart 100.00% <ø> (+5.88%) ⬆️
lib/src/fields/form_builder_date_range_picker.dart 86.11% <0.00%> (ø)
lib/src/fields/form_builder_date_time_picker.dart 86.13% <ø> (ø)
lib/src/fields/form_builder_dropdown.dart 95.00% <ø> (+4.52%) ⬆️
lib/src/fields/form_builder_radio_group.dart 92.30% <ø> (+6.59%) ⬆️
lib/src/fields/form_builder_range_slider.dart 97.05% <ø> (+2.77%) ⬆️
lib/src/fields/form_builder_segmented_control.dart 85.18% <ø> (+3.04%) ⬆️
lib/src/fields/form_builder_slider.dart 100.00% <ø> (+2.94%) ⬆️
... and 5 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@deandreamatias deandreamatias merged commit 5b41d5d into main Apr 22, 2023
4 of 6 checks passed
@deandreamatias deandreamatias deleted the improve-focus-and-scroll branch April 22, 2023 23:32
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.

Change semantics of shouldRequestFocus Disable RequestFocus when calling invalidateField
2 participants