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

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

Open
rezmeplxrf opened this issue Sep 12, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@rezmeplxrf
Copy link

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 rezmeplxrf added the bug Something isn't working label Sep 12, 2024
@MegatronKing
Copy link
Member

@rezmeplxrf Can you provide a minimal reproducible demo?

@rezmeplxrf
Copy link
Author

rezmeplxrf commented Sep 12, 2024

@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,
                ),
              ),
            );
          },
        ),
      ),
    );
  }
}

@MegatronKing
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants