Unverified Commit e3426679 authored by derdilla's avatar derdilla Committed by GitHub

fix Ink not updating on TextField newline (#140700)

Fixes a layout bug when using an EditableText and something containing an Ink widget.
parent ab30122f
...@@ -37,6 +37,7 @@ import 'scroll_position.dart'; ...@@ -37,6 +37,7 @@ import 'scroll_position.dart';
import 'scrollable.dart'; import 'scrollable.dart';
import 'scrollable_helpers.dart'; import 'scrollable_helpers.dart';
import 'shortcuts.dart'; import 'shortcuts.dart';
import 'size_changed_layout_notifier.dart';
import 'spell_check.dart'; import 'spell_check.dart';
import 'tap_region.dart'; import 'tap_region.dart';
import 'text.dart'; import 'text.dart';
...@@ -4951,48 +4952,50 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien ...@@ -4951,48 +4952,50 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
_openInputConnection(); _openInputConnection();
_updateSelectionRects(force: true); _updateSelectionRects(force: true);
}, },
child: _Editable( child: SizeChangedLayoutNotifier(
key: _editableKey, child: _Editable(
startHandleLayerLink: _startHandleLayerLink, key: _editableKey,
endHandleLayerLink: _endHandleLayerLink, startHandleLayerLink: _startHandleLayerLink,
inlineSpan: buildTextSpan(), endHandleLayerLink: _endHandleLayerLink,
value: _value, inlineSpan: buildTextSpan(),
cursorColor: _cursorColor, value: _value,
backgroundCursorColor: widget.backgroundCursorColor, cursorColor: _cursorColor,
showCursor: _cursorVisibilityNotifier, backgroundCursorColor: widget.backgroundCursorColor,
forceLine: widget.forceLine, showCursor: _cursorVisibilityNotifier,
readOnly: widget.readOnly, forceLine: widget.forceLine,
hasFocus: _hasFocus, readOnly: widget.readOnly,
maxLines: widget.maxLines, hasFocus: _hasFocus,
minLines: widget.minLines, maxLines: widget.maxLines,
expands: widget.expands, minLines: widget.minLines,
strutStyle: widget.strutStyle, expands: widget.expands,
selectionColor: _selectionOverlay?.spellCheckToolbarIsVisible ?? false strutStyle: widget.strutStyle,
? _spellCheckConfiguration.misspelledSelectionColor ?? widget.selectionColor selectionColor: _selectionOverlay?.spellCheckToolbarIsVisible ?? false
: widget.selectionColor, ? _spellCheckConfiguration.misspelledSelectionColor ?? widget.selectionColor
textScaler: effectiveTextScaler, : widget.selectionColor,
textAlign: widget.textAlign, textScaler: effectiveTextScaler,
textDirection: _textDirection, textAlign: widget.textAlign,
locale: widget.locale, textDirection: _textDirection,
textHeightBehavior: widget.textHeightBehavior ?? DefaultTextHeightBehavior.maybeOf(context), locale: widget.locale,
textWidthBasis: widget.textWidthBasis, textHeightBehavior: widget.textHeightBehavior ?? DefaultTextHeightBehavior.maybeOf(context),
obscuringCharacter: widget.obscuringCharacter, textWidthBasis: widget.textWidthBasis,
obscureText: widget.obscureText, obscuringCharacter: widget.obscuringCharacter,
offset: offset, obscureText: widget.obscureText,
rendererIgnoresPointer: widget.rendererIgnoresPointer, offset: offset,
cursorWidth: widget.cursorWidth, rendererIgnoresPointer: widget.rendererIgnoresPointer,
cursorHeight: widget.cursorHeight, cursorWidth: widget.cursorWidth,
cursorRadius: widget.cursorRadius, cursorHeight: widget.cursorHeight,
cursorOffset: widget.cursorOffset ?? Offset.zero, cursorRadius: widget.cursorRadius,
selectionHeightStyle: widget.selectionHeightStyle, cursorOffset: widget.cursorOffset ?? Offset.zero,
selectionWidthStyle: widget.selectionWidthStyle, selectionHeightStyle: widget.selectionHeightStyle,
paintCursorAboveText: widget.paintCursorAboveText, selectionWidthStyle: widget.selectionWidthStyle,
enableInteractiveSelection: widget._userSelectionEnabled, paintCursorAboveText: widget.paintCursorAboveText,
textSelectionDelegate: this, enableInteractiveSelection: widget._userSelectionEnabled,
devicePixelRatio: _devicePixelRatio, textSelectionDelegate: this,
promptRectRange: _currentPromptRectRange, devicePixelRatio: _devicePixelRatio,
promptRectColor: widget.autocorrectionTextRectColor, promptRectRange: _currentPromptRectRange,
clipBehavior: widget.clipBehavior, promptRectColor: widget.autocorrectionTextRectColor,
clipBehavior: widget.clipBehavior,
),
), ),
), ),
), ),
......
...@@ -16731,6 +16731,34 @@ void main() { ...@@ -16731,6 +16731,34 @@ void main() {
final EditableTextState state = tester.state<EditableTextState>(find.byType(EditableText)); final EditableTextState state = tester.state<EditableTextState>(find.byType(EditableText));
expect(state.renderEditable.cursorColor, cursorColor.withOpacity(opacity)); expect(state.renderEditable.cursorColor, cursorColor.withOpacity(opacity));
}); });
testWidgets('should notify on size change', (WidgetTester tester) async {
int notifyCount = 0;
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: NotificationListener<SizeChangedLayoutNotification>(
onNotification: (SizeChangedLayoutNotification notification) {
notifyCount += 1;
return false;
},
child: EditableText(
backgroundCursorColor: Colors.grey,
cursorColor: Colors.grey,
controller: controller,
focusNode: focusNode,
maxLines: 3,
minLines: 1,
style: textStyle,
),
),
),
));
expect(notifyCount, equals(0));
await tester.enterText(find.byType(EditableText), '\n');
await tester.pumpAndSettle();
expect(notifyCount, equals(1));
});
} }
class UnsettableController extends TextEditingController { class UnsettableController extends TextEditingController {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment