Skip to content

Conversation

@justinmc
Copy link
Contributor

@justinmc justinmc commented Jul 7, 2023

TextField.canRequestFocus was added in #117504, but it seems to be redundant with the TextField's FocusNode's canRequestFocus parameter. This PR deprecates TextField.canRequestFocus and uses FocusNode.canRequestFocus where it was previously used in DropdownMenu.

Migration guide: flutter/website#8994

Buggy behavior of TextField.canRequestFocus: false

This bug, reported in #130011, still persists after this PR if you set TextField.focusNode.canRequestFocus to false. That issue should stay open to track it. However, now that canRequestFocus is deprecated, it at least is harder to encounter and doesn't seem to be endorsed by the API.

Issue: #130011

@justinmc justinmc requested a review from QuncCccccc July 7, 2023 18:19
@justinmc justinmc self-assigned this Jul 7, 2023
@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jul 7, 2023
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks a lot for providing a better fix for DropdownMenu!

_effectiveFocusNode.canRequestFocus = widget.canRequestFocus && _isEnabled;
_effectiveFocusNode.canRequestFocus = widget.focusNode == null
? widget.canRequestFocus && _isEnabled
: widget.focusNode!.canRequestFocus && _isEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should the indentation be 2-character space?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like there are both 2 and 4 spacing for this kind of ternary in this file haha. I'll normalize it all to 2 spaces.

return widget.canRequestFocus && _isEnabled;
return widget.focusNode == null
? widget.canRequestFocus && _isEnabled
: widget.focusNode!.canRequestFocus && _isEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.

@justinmc
Copy link
Contributor Author

I'm struggling to get the Google tests to run but otherwise this is ready to land.

@justinmc justinmc merged commit 9cda309 into flutter:master Aug 2, 2023
@justinmc justinmc deleted the can-request-focus-dropdown branch August 2, 2023 21:16
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 3, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 3, 2023
flutter/flutter@b3f99ff...c00d241

2023-08-03 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from 9304c0074d29 to 4c1157b9da54 (24 revisions) (flutter/flutter#131830)
2023-08-03 katelovett@google.com Assert against infinite values of control points in CatmullRomSpline (flutter/flutter#131820)
2023-08-02 polinach@google.com Update stack_frame.dart to parse unexpected error format to null. (flutter/flutter#131786)
2023-08-02 jmccandless@google.com Replace TextField.canRequestFocus with TextField.focusNode.canRequestFocus (flutter/flutter#130164)
2023-08-02 ian@hixie.ch Mention that the widget tree is not disposed on exit (flutter/flutter#131637)
2023-08-02 louisehsu@google.com [framework] Add Look Up to selection controls for iOS  (flutter/flutter#131798)
2023-08-02 34871572+gmackall@users.noreply.github.com Add documentation in flutter.groovy noting that we always use the latest available android version (flutter/flutter#131705)
2023-08-02 jonahwilliams@google.com [framework] lerp images in a save layer. (flutter/flutter#131703)
2023-08-02 engine-flutter-autoroll@skia.org Roll Packages from 3dc00c1 to 4e4961a (1 revision) (flutter/flutter#131788)
2023-08-02 ychris@google.com add gem dependency to the ios_app_with_extensions_test (flutter/flutter#131713)
2023-08-02 engine-flutter-autoroll@skia.org Roll Flutter Engine from d6b962d0e36d to 9304c0074d29 (4 revisions) (flutter/flutter#131790)
2023-08-02 christopherfujino@gmail.com [flutter_tools] set terminal.singleCharMode to false after attach finishes (flutter/flutter#131723)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC camillesimon@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
sfshaza2 added a commit to flutter/website that referenced this pull request Aug 3, 2023
Added a migration guide for a deprecation in
flutter/flutter#130164. Still waiting for that
to merge to finish the Timeline section.

## Presubmit checklist

- [x] This PR doesn’t contain automatically generated corrections
(Grammarly or similar).
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.

---------

Co-authored-by: Shams Zakhour (ignore Sfshaza) <44418985+sfshaza2@users.noreply.github.com>
Jasguerrero added a commit that referenced this pull request Aug 8, 2023
Jasguerrero added a commit that referenced this pull request Aug 8, 2023
…nRequestFocus" (#132104)

Reverts #130164

reverting because it cause internal google testing failures b/294917394
Jasguerrero added a commit to Jasguerrero/flutter that referenced this pull request Aug 8, 2023
…nRequestFocus" (flutter#132104)

Reverts flutter#130164

reverting because it cause internal google testing failures b/294917394
Jasguerrero added a commit that referenced this pull request Aug 8, 2023
#132106)

…nRequestFocus" (#132104)

Reverts #130164

reverting because it cause internal google testing failures b/294917394
justinmc added a commit to justinmc/flutter that referenced this pull request Aug 9, 2023
parlough pushed a commit to flutter/website that referenced this pull request Jan 7, 2026
We made a breaking change to remove `TextField.canRequestFocus`
(flutter/flutter#130164). However, this caused a
google3 failure and was reverted
(flutter/flutter#132104).

This removes the breaking change guide since we never relanded this
change:

* flutter/flutter#149067
* flutter/flutter#132273
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.

2 participants