Skip to content

Selection menu not showing when selection is 0,0#49000

Merged
fluttergithubbot merged 2 commits intoflutter:masterfrom
justinmc:select-zero-zero
Jan 17, 2020
Merged

Selection menu not showing when selection is 0,0#49000
fluttergithubbot merged 2 commits intoflutter:masterfrom
justinmc:select-zero-zero

Conversation

@justinmc
Copy link
Contributor

Description

Before this PR, if you set a TextField's controller with a selection of 0,0, then the TextField wouldn't show the selection menu before any text was entered.

TextField(
  controller: TextEditingController.fromValue(
    TextEditingValue(
      selection: TextEditingSelection(baseOffset: 0, extentOffset: 0),
    ),
  ),
),

The problem is that when the user focuses the field, RenderEditable tries to set the selection to 0,0, but it sees that it already is 0,0 and thinks nothing has changed. EditableText is not informed that anything happened, and the selection menu is not created. Usually, selection would be -1,-1 and this would work fine.

This PR considers this situation to be a selection change, so the field will be focused and the selection menu can be shown.

Related Issues

Closes #37798

Tests

  • Test that a long press in a 0,0 field successfully shows the selection menu.

@justinmc justinmc requested a review from gspencergoog January 16, 2020 22:43
@justinmc justinmc self-assigned this Jan 16, 2020
@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jan 16, 2020
@justinmc
Copy link
Contributor Author

@gspencergoog I see you added a similar check in the if statement in this PR, so I added you as a reviewer.

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@fluttergithubbot fluttergithubbot merged commit c61e55a into flutter:master Jan 17, 2020
@justinmc justinmc deleted the select-zero-zero branch January 17, 2020 21:37
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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.

TextField: Bug with Dialog

4 participants