Skip to content

obscureText and enableInteractiveSelection defaults - #24527

Merged
justinmc merged 8 commits into
flutter:masterfrom
justinmc:text-field-obscured-copiable
Dec 13, 2018
Merged

justinmc merged 8 commits into
flutter:masterfrom
justinmc:text-field-obscured-copiable

Conversation

@justinmc

@justinmc justinmc commented Nov 19, 2018 •

Copy link
Copy Markdown
Contributor

Closes #24100

@justinmc justinmc self-assigned this Nov 19, 2018
@justinmc justinmc changed the title WIP obscureText and enableInteractiveSelection defaults obscureText and enableInteractiveSelection defaults Nov 19, 2018
@justinmc
justinmc requested a review from HansMuller November 19, 2018 18:48
@justinmc

Copy link
Copy Markdown
Contributor Author

@HansMuller Ready for review whenever you get a chance. I added docs and tests.

/// {@macro flutter.widgets.editableText.enableInteractiveSelection}
final bool enableInteractiveSelection;

/// Whether or not this field allows text selection.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't quite right, since it's about interactive text selection; you can still programmatically change the selection with the controller.

Sadly, I think it will be necessary to exhaustively explain what this getter means vis. enableInteractiveSelection and obscureText.

Similarly, enabledInteractiveSelection will need to explain its (new) default value, etc.

@justinmc

Copy link
Copy Markdown
Contributor Author

@HansMuller I improved the documentation with your comment. I'm a little bit worried about the relationship between TextField's enableInteractiveSelection and EditableText's property of the same name. They do the same thing but have different defaults. I copied most of the docs but changed the default. Does that look ok to you or is there a better way?

@justinmc
justinmc force-pushed the text-field-obscured-copiable branch from 76b6021 to bff78e4 Compare November 19, 2018 22:42
/// Defaults to false, resulting in a typical blinking cursor.
static bool debugDeterministicCursor = false;

/// {@macro flutter.widgets.editable.selectionEnabled}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Did I set up this macro correctly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes. The template appears in RenderEditable, so the macro tag should be flutter.rendering.editable.selectionEnabled.

@justinmc

Copy link
Copy Markdown
Contributor Author

@HansMuller Updated according to the refactor we talked about.

markNeedsSemanticsUpdate();
}

/// {@template flutter.widgets.editable.selectionEnabled}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The template tag should match the class directory, so flutter.rendering.editable.selectionEnabled.

}

/// {@template flutter.widgets.editable.selectionEnabled}
/// Decides if selection is enabled based on [enableInteractiveSelection] and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

True if interactive selection is enabled based on the values of [enableInteractiveSelection] and [obscureText].

Hopefully the next section will make it clear that the common case is simple.

/// [obscureText] to make the common use case of password fields simple while
/// still allowing selection of obscured text.
///
/// Just setting [obscureText] to true will create a typical Material password

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't refer to Material here, RenderEditable and EditableText are used elsewhere. The simplest way to define this method's value might be to do the case analysis:

  • By default [enableInteractiveSelection] is null, obscureText is false, and this method returns true.
  • If [enableInteractiveSelection] is null, obscureText is true, then this method returns false. This is the common case for password fields.
  • If [enableInteractiveSelection] is non-null then its value is returned. An app might set it to true to enable interactive selection for a password field, or to false to unconditionally disable interactive selection.

/// Defaults to false, resulting in a typical blinking cursor.
static bool debugDeterministicCursor = false;

/// {@macro flutter.widgets.editable.selectionEnabled}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes. The template appears in RenderEditable, so the macro tag should be flutter.rendering.editable.selectionEnabled.

/// If false, most of the accessibility support for selecting text, copy
/// and paste, and moving the caret will be disabled.
/// {@endtemplate}
/// {@macro flutter.widgets.editableText.enableInteractiveSelection}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The @template definition of this macro should appear in rendering/editable.dart.

At the moment it does appear to be defined anywhere.

@justinmc
justinmc force-pushed the text-field-obscured-copiable branch from 1d18347 to dadf737 Compare November 20, 2018 16:34
@justinmc
justinmc force-pushed the text-field-obscured-copiable branch from dadf737 to c33e0f1 Compare November 20, 2018 16:48
@justinmc

Copy link
Copy Markdown
Contributor Author

@HansMuller Updated to address your comments. Let me know if I got everything.

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@justinmc

Copy link
Copy Markdown
Contributor Author

Ready to merge after code freeze.

@zoechi zoechi added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Nov 28, 2018
@justinmc
justinmc merged commit f8f5953 into flutter:master Dec 13, 2018
@justinmc
justinmc deleted the text-field-obscured-copiable branch December 13, 2018 19:09
justinmc added a commit that referenced this pull request Dec 13, 2018
justinmc added a commit that referenced this pull request Dec 13, 2018
justinmc added a commit that referenced this pull request Dec 17, 2018
…#25342)

* Revert "Add imports section to sample code templates, and more docs. (#25184)"

This reverts commit 95b0124.

* Revert "Use stderr instead of stdout to contain errors in flutter attach test (#25305)"

This reverts commit 2b819dd.

* Revert "Allow detection of taps on TabBar (#23919)"

This reverts commit 01694ab.

* Revert "a549981da Roll src/third_party/skia a69b10312977..5eb29448dfbd (1 commits) (flutter-team-archive/engine#7211) (#25333)"

This reverts commit a37099f.

* Revert "Revert "obscureText and enableInteractiveSelection defaults (#24527)" (#25335)"

This reverts commit c545706.

* Password fields are no longer selectable nor copiable
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Obscured text field content is copy-able

4 participants