flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

[Mobile] Paste Behavior

Open matthiasn opened this issue 3 years ago • 5 comments

The behavior when pasting text on iOS is different from native apps such as the notes app that comes with the phone. I'm used to tapping anywhere in a text on iOS, and then the context menu appears immediately. However, with this library, I have to hold for like a second and then let go for the menu to appear. That feels unnatural.

I also tested with the latest version of the example app (on an iPhone 12 Pro), and it is the same behavior there.

matthiasn avatar Nov 25 '21 06:11 matthiasn

This seems OS behavior IIRC. Not something the app controls. But I am not 100% confident.

singerdmx avatar Nov 30 '21 03:11 singerdmx

@singerdmx thanks but this works perfectly fine in other iOS apps.

matthiasn avatar Nov 30 '21 10:11 matthiasn

In the code we are using toolbarOptions Not sure if it is possible to configure the behavior there

singerdmx avatar Dec 05 '21 02:12 singerdmx

image

I think I found where it is shouldShowSelectionToolbar

singerdmx avatar Dec 07 '21 11:12 singerdmx

We investigated it and right now we are assuming showing toolbar (a.k.a context menu) only when !textEditingValue.selection.isCollapsed. See

void _updateOrDisposeSelectionOverlayIfNeeded() {
    if (_selectionOverlay != null) {
      if (_hasFocus && !textEditingValue.selection.isCollapsed) {
        _selectionOverlay!.update(textEditingValue);
      } else {
        _selectionOverlay!.dispose();
        _selectionOverlay = null;
      }
    } else if (_hasFocus) {
      _selectionOverlay?.hide();
      _selectionOverlay = null;

      if (widget.selectionControls != null) {
        _selectionOverlay = EditorTextSelectionOverlay(
          clipboardStatus: _clipboardStatus,
          context: context,
          value: textEditingValue,
          debugRequiredFor: widget,
          toolbarLayerLink: _toolbarLayerLink,
          startHandleLayerLink: _startHandleLayerLink,
          endHandleLayerLink: _endHandleLayerLink,
          renderObject: renderEditor,
          selectionControls: widget.selectionControls,
          selectionDelegate: this,
          dragStartBehavior: DragStartBehavior.start,
          // onSelectionHandleTapped: widget.onSelectionHandleTapped,
        );
        _selectionOverlay!.handlesVisible = _shouldShowSelectionHandles();
        _selectionOverlay!.showHandles();
        // if (widget.onSelectionChanged != null)
        //   widget.onSelectionChanged(selection, cause);
      }
    }
  }

Changing this behavior for onTapDown in delegate.dart or onSingleTapUp in editor.dart introduces a lot of issues. Probably can revisit this in the future.

  @override
  void onSingleTapUp(TapUpDetails details) {
    if (_state.widget.onTapUp != null) {
      final renderEditor = getRenderEditor();
      if (renderEditor != null) {
        if (_state.widget.onTapUp!(
            details, renderEditor.getPositionForOffset)) {
          return;
        }
      }
    }

    **getEditor()!.hideToolbar();**

singerdmx avatar Dec 28 '21 21:12 singerdmx

Thank you for the report, this issue has been open for a while and since there are no interactions with it, we had to close it

but if you still facing this issue, or other issues or you have any other questions, feel free to contact us anytime you want.

EchoEllet avatar Nov 08 '23 18:11 EchoEllet