diff --git a/super_editor/lib/src/super_textfield/android/android_textfield.dart b/super_editor/lib/src/super_textfield/android/android_textfield.dart index 1a957038c..17e0b8b61 100644 --- a/super_editor/lib/src/super_textfield/android/android_textfield.dart +++ b/super_editor/lib/src/super_textfield/android/android_textfield.dart @@ -575,48 +575,54 @@ class SuperAndroidTextFieldState extends State @override Widget build(BuildContext context) { - return TapRegion( - groupId: widget.tapRegionGroupId, - child: Focus( - key: _textFieldKey, - focusNode: _focusNode, - onKeyEvent: _onKeyEventPressed, - child: CompositedTransformTarget( - link: _textFieldLayerLink, - child: AndroidTextFieldTouchInteractor( - focusNode: _focusNode, - tapHandlers: widget.tapHandlers, - textKey: _textContentKey, - getGlobalCaretRect: _getGlobalCaretRect, - textFieldLayerLink: _textFieldLayerLink, - textController: _textEditingController, - editingOverlayController: _editingOverlayController, - textScrollController: _textScrollController, - isMultiline: _isMultiline, - handleColor: widget.handlesColor, - showDebugPaint: widget.showDebugPaint, - child: TextScrollView( - key: _scrollKey, - textScrollController: _textScrollController, + return Semantics( + textField: true, + focusable: true, + focused: _focusNode.hasFocus, + value: _textEditingController.text.toPlainText(), + child: TapRegion( + groupId: widget.tapRegionGroupId, + child: Focus( + key: _textFieldKey, + focusNode: _focusNode, + onKeyEvent: _onKeyEventPressed, + child: CompositedTransformTarget( + link: _textFieldLayerLink, + child: AndroidTextFieldTouchInteractor( + focusNode: _focusNode, + tapHandlers: widget.tapHandlers, textKey: _textContentKey, - textEditingController: _textEditingController, - textAlign: _textAlign, - minLines: widget.minLines, - maxLines: widget.maxLines, - lineHeight: widget.lineHeight, - padding: EdgeInsets.only(top: widget.padding?.top ?? 0, bottom: widget.padding?.bottom ?? 0), - perLineAutoScrollDuration: const Duration(milliseconds: 100), + getGlobalCaretRect: _getGlobalCaretRect, + textFieldLayerLink: _textFieldLayerLink, + textController: _textEditingController, + editingOverlayController: _editingOverlayController, + textScrollController: _textScrollController, + isMultiline: _isMultiline, + handleColor: widget.handlesColor, showDebugPaint: widget.showDebugPaint, - child: FillWidthIfConstrained( - child: Padding( - padding: EdgeInsets.only(left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0), - child: CompositedTransformTarget( - link: _textContentLayerLink, - child: ListenableBuilder( - listenable: _textEditingController, - builder: (context, _) { - return _buildSelectableText(); - }, + child: TextScrollView( + key: _scrollKey, + textScrollController: _textScrollController, + textKey: _textContentKey, + textEditingController: _textEditingController, + textAlign: _textAlign, + minLines: widget.minLines, + maxLines: widget.maxLines, + lineHeight: widget.lineHeight, + padding: EdgeInsets.only(top: widget.padding?.top ?? 0, bottom: widget.padding?.bottom ?? 0), + perLineAutoScrollDuration: const Duration(milliseconds: 100), + showDebugPaint: widget.showDebugPaint, + child: FillWidthIfConstrained( + child: Padding( + padding: EdgeInsets.only(left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0), + child: CompositedTransformTarget( + link: _textContentLayerLink, + child: ListenableBuilder( + listenable: _textEditingController, + builder: (context, _) { + return _buildSelectableText(); + }, + ), ), ), ), diff --git a/super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart b/super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart index f3c1e2403..36ac9f56e 100644 --- a/super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart +++ b/super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart @@ -429,58 +429,64 @@ class SuperDesktopTextFieldState extends State implements final isMultiline = widget.minLines != 1 || widget.maxLines != 1; - return TapRegion( - groupId: widget.tapRegionGroupId, - child: _buildTextInputSystem( - isMultiline: isMultiline, - // As we handle the scrolling gestures ourselves, - // we use NeverScrollableScrollPhysics to prevent SingleChildScrollView - // from scrolling. This also prevents the user from interacting - // with the scrollbar. - // We use a modified version of Flutter's Scrollbar that allows - // configuring it with a different scroll physics. - // - // See https://github.com/superlistapp/super_editor/issues/1628 for more details. - child: ScrollbarWithCustomPhysics( - controller: _scrollController, - physics: ScrollConfiguration.of(context).getScrollPhysics(context), - child: SuperTextFieldGestureInteractor( - focusNode: _focusNode, - textController: _controller, - textKey: _textKey, - textScrollKey: _textScrollKey, - isMultiline: isMultiline, - onRightClick: widget.onRightClick, - tapHandlers: widget.tapHandlers, - child: MultiListenableBuilder( - listenables: { - _focusNode, - _controller, - }, - builder: (context) { - return _buildDecoration( - child: SuperTextFieldScrollview( - key: _textScrollKey, - textKey: _textKey, - textController: _controller, - textAlign: _textAlign, - scrollController: _scrollController, - viewportHeight: _viewportHeight, - estimatedLineHeight: _getEstimatedLineHeight(), - isMultiline: isMultiline, - child: FillWidthIfConstrained( - child: Padding( - // WARNING: Padding within the text scroll view must be placed here, under - // FillWidthIfConstrained, rather than around it, because FillWidthIfConstrained makes - // decisions about sizing that expects its child to fill all available space in the - // ancestor Scrollable. - padding: widget.padding, - child: _buildSelectableText(), + return Semantics( + textField: true, + focusable: true, + focused: _focusNode.hasFocus, + value: _controller.text.toPlainText(), + child: TapRegion( + groupId: widget.tapRegionGroupId, + child: _buildTextInputSystem( + isMultiline: isMultiline, + // As we handle the scrolling gestures ourselves, + // we use NeverScrollableScrollPhysics to prevent SingleChildScrollView + // from scrolling. This also prevents the user from interacting + // with the scrollbar. + // We use a modified version of Flutter's Scrollbar that allows + // configuring it with a different scroll physics. + // + // See https://github.com/superlistapp/super_editor/issues/1628 for more details. + child: ScrollbarWithCustomPhysics( + controller: _scrollController, + physics: ScrollConfiguration.of(context).getScrollPhysics(context), + child: SuperTextFieldGestureInteractor( + focusNode: _focusNode, + textController: _controller, + textKey: _textKey, + textScrollKey: _textScrollKey, + isMultiline: isMultiline, + onRightClick: widget.onRightClick, + tapHandlers: widget.tapHandlers, + child: MultiListenableBuilder( + listenables: { + _focusNode, + _controller, + }, + builder: (context) { + return _buildDecoration( + child: SuperTextFieldScrollview( + key: _textScrollKey, + textKey: _textKey, + textController: _controller, + textAlign: _textAlign, + scrollController: _scrollController, + viewportHeight: _viewportHeight, + estimatedLineHeight: _getEstimatedLineHeight(), + isMultiline: isMultiline, + child: FillWidthIfConstrained( + child: Padding( + // WARNING: Padding within the text scroll view must be placed here, under + // FillWidthIfConstrained, rather than around it, because FillWidthIfConstrained makes + // decisions about sizing that expects its child to fill all available space in the + // ancestor Scrollable. + padding: widget.padding, + child: _buildSelectableText(), + ), ), ), - ), - ); - }, + ); + }, + ), ), ), ), diff --git a/super_editor/lib/src/super_textfield/ios/ios_textfield.dart b/super_editor/lib/src/super_textfield/ios/ios_textfield.dart index ef8886f1e..e5fc04533 100644 --- a/super_editor/lib/src/super_textfield/ios/ios_textfield.dart +++ b/super_editor/lib/src/super_textfield/ios/ios_textfield.dart @@ -575,47 +575,53 @@ class SuperIOSTextFieldState extends State @override Widget build(BuildContext context) { - return TapRegion( - groupId: widget.tapRegionGroupId, - child: Focus( - key: _textFieldKey, - focusNode: _focusNode, - child: CompositedTransformTarget( - link: _textFieldLayerLink, - child: IOSTextFieldTouchInteractor( - focusNode: _focusNode, - tapHandlers: widget.tapHandlers, - selectableTextKey: _textContentKey, - getGlobalCaretRect: _getGlobalCaretRect, - textFieldLayerLink: _textFieldLayerLink, - textController: _textEditingController, - editingOverlayController: _editingOverlayController, - textScrollController: _textScrollController, - isMultiline: _isMultiline, - handleColor: widget.handlesColor, - showDebugPaint: widget.showDebugPaint, - child: TextScrollView( - key: _scrollKey, + return Semantics( + textField: true, + focusable: true, + focused: _focusNode.hasFocus, + value: _textEditingController.text.toPlainText(), + child: TapRegion( + groupId: widget.tapRegionGroupId, + child: Focus( + key: _textFieldKey, + focusNode: _focusNode, + child: CompositedTransformTarget( + link: _textFieldLayerLink, + child: IOSTextFieldTouchInteractor( + focusNode: _focusNode, + tapHandlers: widget.tapHandlers, + selectableTextKey: _textContentKey, + getGlobalCaretRect: _getGlobalCaretRect, + textFieldLayerLink: _textFieldLayerLink, + textController: _textEditingController, + editingOverlayController: _editingOverlayController, textScrollController: _textScrollController, - textKey: _textContentKey, - textEditingController: _textEditingController, - textAlign: _textAlign, - minLines: widget.minLines, - maxLines: widget.maxLines, - lineHeight: widget.lineHeight, - padding: EdgeInsets.only(top: widget.padding?.top ?? 0, bottom: widget.padding?.bottom ?? 0), - perLineAutoScrollDuration: const Duration(milliseconds: 100), + isMultiline: _isMultiline, + handleColor: widget.handlesColor, showDebugPaint: widget.showDebugPaint, - child: FillWidthIfConstrained( - child: Padding( - padding: EdgeInsets.only(left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0), - child: CompositedTransformTarget( - link: _textContentLayerLink, - child: ListenableBuilder( - listenable: _textEditingController, - builder: (context, _) { - return _buildSelectableText(); - }, + child: TextScrollView( + key: _scrollKey, + textScrollController: _textScrollController, + textKey: _textContentKey, + textEditingController: _textEditingController, + textAlign: _textAlign, + minLines: widget.minLines, + maxLines: widget.maxLines, + lineHeight: widget.lineHeight, + padding: EdgeInsets.only(top: widget.padding?.top ?? 0, bottom: widget.padding?.bottom ?? 0), + perLineAutoScrollDuration: const Duration(milliseconds: 100), + showDebugPaint: widget.showDebugPaint, + child: FillWidthIfConstrained( + child: Padding( + padding: EdgeInsets.only(left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0), + child: CompositedTransformTarget( + link: _textContentLayerLink, + child: ListenableBuilder( + listenable: _textEditingController, + builder: (context, _) { + return _buildSelectableText(); + }, + ), ), ), ),