Skip to content

Conversation

@stevenmetzger
Copy link

@stevenmetzger stevenmetzger commented Jan 20, 2021

This PR adds support the optional argument (forceSubmitOnFocusLost) to TextField. This is needed to complete work on flutter/engine#22517. This PR was requested during review flutter/engine#22517 (review).

This fixes the following regression:
Fixes #64245

This fix was proposed in the comments of this issue here:
#64245 (comment)

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

* Add optional argument (forceCloseConnectionOnBlur) to TextField
* This PR is meant to accompany this change to flutter/engine
  flutter/engine#22517
@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jan 20, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@LongCatIsLooong
Copy link
Contributor

oops sorry I'll take a look tonight.

this.autofocus = false,
this.obscuringCharacter = '•',
this.obscureText = false,
this.forceCloseConnectionOnBlur = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't mention "connection" in the text field api. Even to EditableText if feels the "connection" should be an implementation detail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, connection should be an implementation detail. I changed this to forceSubmitOnFocusLost, because the onSubmitted callback will be invoked when the user clicks out of the text field.

/// Defaults to false.
final bool obscureText;

/// Previously, Flutter for Web behaved like a web page. If user clicked on an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most developers won't be too interested in the story behind the parameter. These should probably be code comments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the story and included a brief description of the behavior.

/// https://github.com/flutter/flutter/issues/64245
///
/// This flag provides a workaround to the regression allowing developers to
/// optionally force the connection to close on blur, as suggested in the comments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain in the documentation what "blur" means?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed "blur" to "focus lost". Blur is the opposite of focus, but saying "focus lost" is probably easier to understand.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@Fabrice-TEICHTEIL-KOENIGSBUCH

@LongCatIsLooong is there anything still to be done following last review cycle?

@Piinks
Copy link
Contributor

Piinks commented Jun 10, 2021

(triage) Hi @stevenmetzger would you like to continue with this change?

@stevenmetzger
Copy link
Author

Hi @Piinks, yes I would like to continue with this change. But it's been here for so long that the corresponding change to flutter/engine is out of date. If I were to rebase both of these changes would they go through? What is the next step to continue here? Sorry for being unfamiliar with the process, this is my first commit to this project.

@jonahwilliams
Copy link
Contributor

From my reading of flutter/engine#22517 , it sounds like this might be fixed via #82575

@Piinks
Copy link
Contributor

Piinks commented Jun 10, 2021

Thanks @jonahwilliams! @stevenmetzger can you confirm that the issue you were trying to resolve is fixed? If so, we can close these changes.

@Fabrice-TEICHTEIL-KOENIGSBUCH

Hi @Piinks @jonahwilliams we opened the issue that this PR fixes: https://github.com/flutter/flutter/issues/64245#issuecomment-681815149.
I don't think that https://github.com/flutter/flutter/pull/82575 will provide a complete solution to our problem.
We need a behavior similar to Google Sheets: when a user clicks or taps outside of a text field, the value should be submitted to the backend immediately, both for web and mobile.
I believe the current PR addresses both platforms, as well as taps in addition to mouse clicks.
And it is pretty efficient and simple to use with just a parameter to set :)
We would love to see it eventually landed, but it is stuck in review for months.

@jonahwilliams
Copy link
Contributor

In that case I don't believe you need an engine change, just an update to the text field to submit when focus is lost.

@Piinks Piinks added the a: text input Entering text in a text field or keyboard related problems label Aug 17, 2021
@Piinks
Copy link
Contributor

Piinks commented Aug 17, 2021

This PR has not been updated in a while, and it currently is failing several tests. I am going to close it for now, but if you would like to return to this change, please feel free to re-open it. Thank you for the contribution!

@Piinks Piinks closed this Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] TextFormField does not get blurred when tapped outside of the widget.

5 participants