suragch / mongol

Mongolian vertical script widgets for Flutter apps
https://pub.dev/packages/mongol
BSD 3-Clause "New" or "Revised" License
70 stars 15 forks source link

Found the solution: Flutter 2.5 update causes app to freeze if the cursor has to scroll out of view. #22

Closed Satsrag closed 1 year ago

Satsrag commented 2 years ago

The issue occurred in paint(PaintingContext context, Offset offset) method of MongolRenderEditable class . The has issue code:

  @override
  void paint(PaintingContext context, Offset offset) {
    _layoutText(
        minHeight: constraints.minHeight, maxHeight: constraints.maxHeight);
    if (_hasVisualOverflow && clipBehavior != Clip.none) {
      _clipRectLayer = context.pushClipRect(
        needsCompositing,
        offset,
        Offset.zero & size,
        _paintContents,
        clipBehavior: clipBehavior,
        oldLayer: _clipRectLayer,
      );
    } else {
      _clipRectLayer = null;
      _paintContents(context, offset);
    }
    _paintHandleLayers(context, getEndpointsForSelection(selection!));
  }

  ClipRectLayer? _clipRectLayer;

The solution code:

  @override
  void paint(PaintingContext context, Offset offset) {
    _layoutText(
        minHeight: constraints.minHeight, maxHeight: constraints.maxHeight);
    if (_hasVisualOverflow && clipBehavior != Clip.none) {
      _clipRectLayer.layer = context.pushClipRect(
        needsCompositing,
        offset,
        Offset.zero & size,
        _paintContents,
        clipBehavior: clipBehavior,
        oldLayer: _clipRectLayer.layer,
      );
    } else {
      _clipRectLayer.layer = null;
      _paintContents(context, offset);
    }
    _paintHandleLayers(context, getEndpointsForSelection(selection!));
  }

  final LayerHandle<ClipRectLayer> _clipRectLayer = LayerHandle<ClipRectLayer>();

The _clipRectLayer has been disposed when call context.pushClipRect method. So use LayerHandle to prevent _clipRectLayer from disposing. The solution code copy from flutter source RenderEditable.

suragch commented 2 years ago

That's great! I wish I had had your solution before! In the current version of the mongol package I've completely removed MongolRenderEditable and the other related classes from the library. My hope has been to reimplement them based on the super_editor package, but I haven't had time. However, if you've found a solution to the previous error, it may be faster to use your solution first. What do you think about adding your solution on a new branch? Then we can test it. If everything is working we can merge it into the main branch.

Satsrag commented 2 years ago

I try to go back to the previous version of the mongol package to check out the new branch and then add the solution. But when I merge it to the master branch, some MongolTextFiled related code was deleted again. So I think checkout the new branch from the current version of the mongol package and then copy the MongolTextFiled related code from the previous version. Then add the solution and others?

suragch commented 2 years ago

Yes, let's not merge into the master branch for now. Let's create a new branch. Then people can use that branch if they need your fixed MongolTextField. Should I create a new branch?

Satsrag commented 2 years ago

Yes .

suragch commented 2 years ago

I created a new branch from master named editor-fixes. Feel free to modify this branch however you like.

Satsrag commented 2 years ago

I pull request to the editor-fixes branch #23. Please search todo editor-fixes to check my modified part.

suragch commented 1 year ago

I think the editor-fixes branch is almost ready to merge into master. It's really nice to see the editor widget working again.

I've pushed a few minor cleanup changes to that branch. Before we merge, though, we should evaluate these issues:

suragch commented 1 year ago

@Satsrag I've merged your changes into the master branch. Everything seems to be working well enough. I need to update the documentation and then I'll publish the update to Pub as Version 3.1.0. If you know of any issues that should be fixed first, please open another issue.

suragch commented 1 year ago

I've published your fixes in version 3.1. In addition to fixing the scrolling issue, it's also great to have the arrow keys working on web and desktop. Thank you very much!