re-editor icon indicating copy to clipboard operation
re-editor copied to clipboard

Unable to use scroll when CodeAutocomplete is nested within another scrollable widget

Open rezmeplxrf opened this issue 1 year ago • 3 comments

Hi First of all, thank you for this amazing package.

Tested environment: MacOS, Web

When I put CodeAutocomplete within a ListView widget, I noticed that scroll won't work within CodeAutocomplete while on MacOS. However the scroll correctly works on Web.

rezmeplxrf avatar Sep 12 '24 12:09 rezmeplxrf

@rezmeplxrf Can you provide a minimal reproducible demo?

MegatronKing avatar Sep 12 '24 13:09 MegatronKing

@rezmeplxrf Can you provide a minimal reproducible demo?

On web scrolling works, but on MacOS, it does not work within the Widget (only works outside the widget).


import 'package:re_editor/re_editor.dart';

import 'package:flutter/material.dart';

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

  @override
  State<StatefulWidget> createState() => _AutoCompleteEditorState();
}

class _AutoCompleteEditorState extends State<AutoCompleteEditor> {
  final List<CodeLineEditingController> _controllers =
      List.generate(5, (_) => CodeLineEditingController());

  @override
  void initState() {
    super.initState();
    const text = "Long Text\nLong Text";

    for (var controller in _controllers) {
      for (var v = 0; v < 20; v++) {
        controller.text += text;
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListView.builder(
          itemCount: _controllers.length,
          itemBuilder: (context, index) {
            final controller = _controllers[index];
            return SizedBox(
              height: 500,
              child: CodeAutocomplete(
                viewBuilder: (context, notifier, onSelected) {
                  return _DefaultCodeAutocompleteListView(
                    notifier: notifier,
                    onSelected: onSelected,
                  );
                },
                promptsBuilder: DefaultCodeAutocompletePromptsBuilder(
                  language: langDart,
                  directPrompts: [],
                ),
                child: CodeEditor(
                  controller: controller,
                  wordWrap: false,
                ),
              ),
            );
          },
        ),
      ),
    );
  }
}

rezmeplxrf avatar Sep 12 '24 17:09 rezmeplxrf

I want to apologize, I forgot to respond to this issue.

In fact, embedding the editor inside other scroll layouts is not supported, and we recommend avoiding this in your UX design.

MegatronKing avatar Oct 31 '24 05:10 MegatronKing