-
Notifications
You must be signed in to change notification settings - Fork 249
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
[SuperTextField] Fix text capitalization configuration (Resolves #1617) #1619
Merged
matthew-carroll
merged 3 commits into
superlistapp:main
from
angelosilvestre:1617_text_capitalization
Nov 27, 2023
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
super_editor/lib/src/infrastructure/flutter/text_input_configuration.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
extension TextInputConfigurationEquivalency on TextInputConfiguration { | ||
/// Whether this [TextInputConfiguration] is equivalent to [other]. | ||
/// | ||
/// Two [TextInputConfiguration]s are considered to be equal | ||
/// if all properties are equal. | ||
bool isEquivalentTo(TextInputConfiguration other) { | ||
return inputType == other.inputType && | ||
readOnly == other.readOnly && | ||
obscureText == other.obscureText && | ||
autocorrect == other.autocorrect && | ||
autofillConfiguration.isEquivalentTo(other.autofillConfiguration) && | ||
smartDashesType == other.smartDashesType && | ||
smartQuotesType == other.smartQuotesType && | ||
enableSuggestions == other.enableSuggestions && | ||
enableInteractiveSelection == other.enableInteractiveSelection && | ||
actionLabel == other.actionLabel && | ||
inputAction == other.inputAction && | ||
textCapitalization == other.textCapitalization && | ||
keyboardAppearance == other.keyboardAppearance && | ||
enableIMEPersonalizedLearning == other.enableIMEPersonalizedLearning && | ||
enableDeltaModel == other.enableDeltaModel && | ||
const DeepCollectionEquality().equals(allowedMimeTypes, other.allowedMimeTypes); | ||
} | ||
} | ||
|
||
extension AutofillConfigurationEquivalency on AutofillConfiguration { | ||
/// Whether this [AutofillConfiguration] is equivalent to [other]. | ||
/// | ||
/// Two [AutofillConfiguration]s are considered to be equal | ||
/// if all properties are equal. | ||
bool isEquivalentTo(AutofillConfiguration other) { | ||
return enabled == other.enabled && | ||
uniqueIdentifier == other.uniqueIdentifier && | ||
const DeepCollectionEquality().equals(autofillHints, other.autofillHints) && | ||
currentEditingValue == other.currentEditingValue && | ||
hintText == other.hintText; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wanted to point one thing out that might be relevant. I checked the API for
AutofillConfiguration
and it seems to include the currentTextEditingValue
. That suggests to me that every time the user types a character, deletes a character, or moves the caret, the overallTextInputConfiguration
will be seen as unequal. Do you also see it that way? If so, do we really want that configuration getting sent every time those things happen?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.
As this is a configuration, I would expect that
AutofillConfiguration
stores only the initialTextEditingValue
without updating it at every keystroke, but the docs aren't clear about that and I've never used theAutofillConfiguration
before.I don't think we want to consider the
TextInputConfiguration
unequal at everyTextEditingValue
. Should I remove it from the comparison?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 think the safest thing is probably to remove it. Please add a comment mentioning that we don't include it in the comparison, and why we don't.
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.
Updated.