-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Fix: On the Web, cannot support multiline inputting when registering customized TextInputControl #139446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: On the Web, cannot support multiline inputting when registering customized TextInputControl #139446
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,7 +89,8 @@ enum SmartQuotesType { | |
| class TextInputType { | ||
| const TextInputType._(this.index) | ||
| : signed = null, | ||
| decimal = null; | ||
| decimal = null, | ||
| forceMultiline = null; | ||
|
|
||
| /// Optimize for numerical information. | ||
| /// | ||
|
|
@@ -98,7 +99,15 @@ class TextInputType { | |
| const TextInputType.numberWithOptions({ | ||
| this.signed = false, | ||
| this.decimal = false, | ||
| }) : index = 2; | ||
| }) : index = 2, forceMultiline = null; | ||
|
|
||
| /// Optimize for none information. | ||
| /// | ||
| /// Requests a none keyboard with additional settings. | ||
| /// The [forceMultiline] parameter is optional. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a comment about how
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also we should probably explain why someone might use this i.e. the custom text input control use-case. |
||
| const TextInputType.noneWithOptions({ | ||
| this.forceMultiline = false, | ||
| }) : index = 10, signed = null, decimal = null; | ||
|
|
||
| /// Enum value index, corresponds to one of the [values]. | ||
| final int index; | ||
|
|
@@ -115,6 +124,12 @@ class TextInputType { | |
| /// Use `const TextInputType.numberWithOptions(decimal: true)` to set this. | ||
| final bool? decimal; | ||
|
|
||
| /// The none is force multiline, allowing a multiline text input. | ||
| /// | ||
| /// This flag is only used for the [none] input type, otherwise `null`. | ||
| /// Use `const TextInputType.noneWithOptions(forceMultiline: true)` to set this. | ||
| final bool? forceMultiline; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| /// Optimize for textual information. | ||
| /// | ||
| /// Requests the default platform keyboard. | ||
|
|
@@ -182,7 +197,7 @@ class TextInputType { | |
| static const TextInputType streetAddress = TextInputType._(9); | ||
|
|
||
| /// Prevent the OS from showing the on-screen virtual keyboard. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a comment similar to how |
||
| static const TextInputType none = TextInputType._(10); | ||
| static const TextInputType none = TextInputType.noneWithOptions(); | ||
|
|
||
| /// All possible enum values. | ||
| static const List<TextInputType> values = <TextInputType>[ | ||
|
|
@@ -203,6 +218,7 @@ class TextInputType { | |
| 'name': _name, | ||
| 'signed': signed, | ||
| 'decimal': decimal, | ||
| 'forceMultiline': forceMultiline, | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -211,19 +227,21 @@ class TextInputType { | |
| return '${objectRuntimeType(this, 'TextInputType')}(' | ||
| 'name: $_name, ' | ||
| 'signed: $signed, ' | ||
| 'decimal: $decimal)'; | ||
| 'decimal: $decimal, ' | ||
| 'forceMultiline: $forceMultiline)'; | ||
| } | ||
|
|
||
| @override | ||
| bool operator ==(Object other) { | ||
| return other is TextInputType | ||
| && other.index == index | ||
| && other.signed == signed | ||
| && other.decimal == decimal; | ||
| && other.decimal == decimal | ||
| && other.forceMultiline == forceMultiline; | ||
| } | ||
|
|
||
| @override | ||
| int get hashCode => Object.hash(index, signed, decimal); | ||
| int get hashCode => Object.hash(index, signed, decimal, forceMultiline); | ||
| } | ||
|
|
||
| /// An action the user has requested the text input control to perform. | ||
|
|
@@ -2226,7 +2244,9 @@ class _PlatformTextInputControl with TextInputControl { | |
| Map<String, dynamic> _configurationToJson(TextInputConfiguration configuration) { | ||
| final Map<String, dynamic> json = configuration.toJson(); | ||
| if (TextInput._instance._currentControl != _PlatformTextInputControl.instance) { | ||
| json['inputType'] = TextInputType.none.toJson(); | ||
| json['inputType'] = TextInputType.noneWithOptions( | ||
| forceMultiline: configuration.inputType == TextInputType.multiline, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I understand we should still continue to send
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Renzo-Olivares Yes, this won't show the keyboard again. This still sends
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated the PR in the web engine to handle |
||
| ); | ||
| } | ||
| return json; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On looking at the
_configurationToJsonchange, this doesn't have to change the public interface at all I think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. I will try it on
_configurationToJsonand just change the JSON that is sent to theengine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I open a new PR. Just added
forceMultilineflag to JSON. @Renzo-Olivares @LongCatIsLooong please have a review.