-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsfound in release: 2.2Found to occur in 2.2Found to occur in 2.2frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Description
The following test fails:
test('FilteringTextInputFormatter should filter independent of selection', () {
final TextInputFormatter formatter = FilteringTextInputFormatter.deny('abc', replacementString: '*');
const TextEditingValue oldValue = TextEditingValue();
const TextEditingValue newValue = TextEditingValue(text: 'abcabcabc');
final String filteredText = formatter.formatEditUpdate(oldValue, newValue).text;
for (int i = 0; i < newValue.text.length; i += 1) {
final String text = formatter.formatEditUpdate(
oldValue,
newValue.copyWith(selection: TextSelection.collapsed(offset: i)),
).text;
expect(filteredText, text);
}
});because currently the text is not formatted as a single string:
flutter/packages/flutter/lib/src/services/text_formatter.dart
Lines 542 to 551 in f2417e6
| final String beforeSelection = substringManipulation( | |
| value.text.substring(0, selectionStartIndex), | |
| ); | |
| final String inSelection = substringManipulation( | |
| value.text.substring(selectionStartIndex, selectionEndIndex), | |
| ); | |
| final String afterSelection = substringManipulation( | |
| value.text.substring(selectionEndIndex), | |
| ); | |
| manipulatedText = beforeSelection + inSelection + afterSelection; |
Simpler1
Metadata
Metadata
Assignees
Labels
a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsfound in release: 2.2Found to occur in 2.2Found to occur in 2.2frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on