singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.58k stars 829 forks source link

Cant scroll when not in focus (keyboard closed) #1841

Closed Sesa1988 closed 2 months ago

Sesa1988 commented 6 months ago

Is there an existing issue for this?

Flutter Quill version

9.3.1

Steps to reproduce

  1. Save long note anywhere
  2. Open new child route with editor without focus and long note text

Expected results

Long text is displayed and can be scrolled without clicking into it and have to open the keyboard

Actual results

Long text is displayed but cant be scrolled and somehow lags. When you click in, it scrolls around to the position where you would except you should be.

Code sample

Code sample ```dart import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_quill/flutter_quill.dart'; import 'package:flutter_quill/quill_delta.dart'; import 'package:foxynotes/app_localizations.dart'; import 'package:foxynotes/blocs/settings/settings_bloc.dart'; import 'package:foxynotes/screens/note_details/bloc/note_details_bloc.dart'; class NoteEditor extends StatefulWidget { final String _content; final FocusNode _focusNode; final bool _shouldFocus; const NoteEditor(this._content, this._focusNode, this._shouldFocus, {super.key}); @override State createState() => _NoteEditor(); } class _NoteEditor extends State { final QuillController _controller = QuillController.basic(); @override void initState() { var document = _loadDocument(widget._content); _controller.document = document; _initNotusController(); super.initState(); } @override Widget build(BuildContext context) { var showBigToolbar = context.select((x) => x.isBigNotesToolbarEnabled); return Column( children: [ Expanded( child: QuillEditor.basic( configurations: QuillEditorConfigurations( controller: _controller, placeholder: AppLocalizations.of(context).translate('note'), readOnly: false, scrollable: true, expands: true, autoFocus: widget._shouldFocus, padding: const EdgeInsets.only(left: 18, right: 18), sharedConfigurations: const QuillSharedConfigurations( locale: Locale('en'), ), ), focusNode: widget._focusNode, scrollController: ScrollController(), ), ), Padding( padding: const EdgeInsets.only(bottom: 8), child: QuillToolbar.simple( configurations: QuillSimpleToolbarConfigurations( controller: _controller, showFontFamily: false, showFontSize: false, showSubscript: false, showSuperscript: false, multiRowsDisplay: showBigToolbar, showRedo: true, showUndo: true, buttonOptions: QuillSimpleToolbarButtonOptions( base: QuillToolbarBaseButtonOptions( iconSize: showBigToolbar ? 14 : 16, ), ), sectionDividerSpace: showBigToolbar ? 0 : 16, toolbarSectionSpacing: showBigToolbar ? 0 : 4, headerStyleType: HeaderStyleType.original, sharedConfigurations: const QuillSharedConfigurations( locale: Locale('en'), ), ), ), ), ], ); } @override void dispose() { _controller.dispose(); super.dispose(); } Document _loadDocument(String jsonString) { if (jsonString == '') { final Delta delta = Delta()..insert('\n'); return Document.fromDelta(delta); } final document = Document.fromJson(jsonDecode(jsonString)); return document; } _initNotusController() { _controller.addListener(() { final previewText = _controller.document.toPlainText().trim(); context.read().add( UpdateNoteContent( jsonEncode(_controller.document.toDelta().toJson()), previewText, ), ); }); } } ```
putnokiabel commented 4 months ago

Hi @Sesa1988 ! I believe I'm running into a similar issue. Have you found any workaround?

Sesa1988 commented 4 months ago

Hi @Sesa1988 ! I believe I'm running into a similar issue. Have you found any workaround?

No I have not found any workaround.

AtlasAutocode commented 2 months ago

I am currently working on issue 1907 which referenced your issue.

Can you tell me more about how you are creating your editor instances. For example, are you switching between tabs or creating new editor instances.

Open new child route with editor without focus and long note text

What is 'route'? Issue 1907 selects the editor instance in the second tab. The content cannot be scrolled until something is selected in that window.

Is your issue similar or different???

Sesa1988 commented 2 months ago

I am currently working on issue 1907 which referenced your issue.

Can you tell me more about how you are creating your editor instances. For example, are you switching between tabs or creating new editor instances.

Open new child route with editor without focus and long note text

What is 'route'? Issue 1907 selects the editor instance in the second tab. The content cannot be scrolled until something is selected in that window.

Is your issue similar or different???

Yes, it sounds like my issue.

I push a new view via pushNamed and pass the content via initState.

I cannot scroll until I click in the editor. When I try to scroll without click into it and click later it will jump down like I scrolled.

Sesa1988 commented 2 months ago

I am currently working on issue 1907 which referenced your issue.

Can you tell me more about how you are creating your editor instances. For example, are you switching between tabs or creating new editor instances.

Open new child route with editor without focus and long note text

What is 'route'? Issue 1907 selects the editor instance in the second tab. The content cannot be scrolled until something is selected in that window.

Is your issue similar or different???

I can confirm that it also fixed my issue.