Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android interactor assumes global positions which delays auto scrolling #2000

Closed
jellynoone opened this issue May 14, 2024 · 0 comments · Fixed by #2036
Closed

Android interactor assumes global positions which delays auto scrolling #2000

jellynoone opened this issue May 14, 2024 · 0 comments · Fixed by #2036
Assignees
Labels
area_supereditor Pertains to SuperEditor bounty_junior f:superlist Funded by Superlist platform_android Applies to use on Android time:2 type_bug Something isn't working

Comments

@jellynoone
Copy link

jellynoone commented May 14, 2024

Package Version
stable

To Reproduce
Steps to reproduce the behavior:

  1. Run the example on Android (the bug affects Android handlers / interactor)
  2. Scroll down to the end of the document
  3. Long press on a word
  4. Drag one of the extended handlers towards the top of the screen
  5. Observe how the document only begins to auto-scroll after dragging over the app header

Minimal Reproduction Code

Minimal, Runnable Code Sample
import 'package:flutter/material.dart';
import 'package:super_editor/super_editor.dart';

void main() {
runApp(const MainApp());
}

class MainApp extends StatefulWidget {
const MainApp({super.key});

@override
State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
final _document = MutableDocument(nodes: [
  for (var i = 0; i < 40; i++)
    ParagraphNode(
      id: Editor.createNodeId(),
      text: AttributedText('Some random text. ' * (1 + i)),
    ),
]);
final _composer = MutableDocumentComposer();
late final _editor = createDefaultDocumentEditor(
  composer: _composer,
  document: _document,
);

@override
void dispose() {
  _editor.dispose();
  _document.dispose();
  _composer.dispose();
  super.dispose();
}

@override
Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      appBar: const PreferredSize(
        preferredSize: Size(double.infinity, 90),
        child: SafeArea(
          child: SizedBox(
            height: 90,
            child: ColoredBox(color: Colors.black),
          ),
        ),
      ),
      body: SuperEditor(
        editor: _editor,
        document: _document,
        composer: _composer,
      ),
    ),
  );
}
}

Actual behavior
Currently, on Android, autoscroll is only started after dragging the over the scaffold's header. On iOS, the autoscroll happens immediately at the boundary of the document.

Expected behavior
The auto-scroll should begin before the start of the document and not above it.
(It would also be nice to be able to control where the scroll start boundary is. It seems the bits are already there just not exposed through SuperEditor)

Platform
Android

Flutter version

Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5dcb86f68f (5 days ago) • 2024-05-09 07:39:20 -0500
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.3

Additional context
Originally, I wanted to adapt the example above to always use the Android gesture mode, however, it seems that setting gestureMode only effects selection styling. Popover toolbar and selection handlers are not displayed. It seems this is because SuperEditorAndroidHandlesDocumentLayerBuilder and other builders test for the defaultTargetPlatform to decide whether to build or not thus ignorring the gestureMode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area_supereditor Pertains to SuperEditor bounty_junior f:superlist Funded by Superlist platform_android Applies to use on Android time:2 type_bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants