Skip to content

Conversation

@Renzo-Olivares
Copy link
Contributor

@Renzo-Olivares Renzo-Olivares commented Feb 6, 2025

Fixes #25553

On iOS single-line TextFields are not scrollable with user input, for example a pan gesture to move the viewport. They can still be scrolled when the user drags the selection handles. Scrolling remains the same for multi-line TextFields. A user can override this by providing CupertinoTextField/TextField/EditableText with a custom scrollPhysics.

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 signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@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. and removed f: material design flutter/packages/flutter/material repository. labels Feb 6, 2025
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍 . Solid simple fix, we should have done something like this a long time ago.

}

class _NeverUserScrollableScrollPhysics extends ScrollPhysics {
/// Creates scroll physics that does not let the user scroll, but allows for programatic scrolling.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Maybe say that it does not let the user scroll "by dragging" or "by panning" to be more specific? Or maybe I'm being too pedantic.

);

testWidgets(
'single-line field cannot be scroll with touch on iOS',
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit "be scroll" => "be scrolled"

physics: widget.scrollPhysics,
// On iOS a single-line TextField should not scroll.
physics:
widget.scrollPhysics ??
Copy link
Contributor

@justinmc justinmc Feb 18, 2025

Choose a reason for hiding this comment

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

I'm glad this is overridable if the developer still wants to enable scrolling 👍

axisDirection: _isMultiline ? AxisDirection.down : AxisDirection.right,
controller: _scrollController,
physics: widget.scrollPhysics,
// On iOS a single-line TextField should not scroll.
Copy link
Contributor

Choose a reason for hiding this comment

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

Good call explaining this.

@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.

@Renzo-Olivares Renzo-Olivares force-pushed the cupertino-editable-horizontal-scrolling branch from 46c1177 to 85567c7 Compare April 15, 2025 00:12
@Renzo-Olivares Renzo-Olivares force-pushed the cupertino-editable-horizontal-scrolling branch from d6112dd to 6d69ced Compare April 15, 2025 21:51
@github-actions github-actions bot added the f: material design flutter/packages/flutter/material repository. label Apr 15, 2025
@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 23, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Apr 23, 2025
Merged via the queue into flutter:master with commit 03b7c23 Apr 23, 2025
75 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 23, 2025
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
…2841)

Fixes flutter#25553 

On iOS single-line TextFields are not scrollable with user input, for
example a pan gesture to move the viewport. They can still be scrolled
when the user drags the selection handles. Scrolling remains the same
for multi-line TextFields. A user can override this by providing
CupertinoTextField/TextField/EditableText with a custom `scrollPhysics`.

## Pre-launch Checklist

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

---------

Co-authored-by: Renzo Olivares <[email protected]>
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.

CupertinoTextField should not allow horizontal scrolling

2 participants