Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/fleather/lib/src/widgets/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,8 @@ class RawEditorState extends EditorState
bool _showCaretOnScreenScheduled = false;

void _showCaretOnScreen([bool withAnimation = true]) {
if (!widget.showCursor ||
if (!_hasFocus ||
!widget.showCursor ||
!widget.enableInteractiveSelection ||
_showCaretOnScreenScheduled) {
return;
Expand Down
38 changes: 38 additions & 0 deletions packages/fleather/test/widgets/editor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,44 @@ void main() {
await tester.pump(throttleDuration);
});

testWidgets('does not reveal cursor or editor when not focused',
(tester) async {
final scrollController = ScrollController();
final controller = FleatherController();
final widget = MaterialApp(
home: SingleChildScrollView(
controller: scrollController,
child: SizedBox(
width: double.maxFinite,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (var i = 0; i < 20; i++) ...[
FleatherField(
key: Key('Field.Key.$i'),
focusNode: FocusNode(),
scrollable: false,
autofocus: true,
showCursor: true,
autocorrect: false,
enableSuggestions: false,
controller: i == 15 ? controller : FleatherController(),
)
]
],
),
),
),
);
await tester.pumpWidget(widget);
final initialScrollPosition = scrollController.position.pixels;
final newInput = 'Line1\nLine2';
controller.replaceText(0, 0, newInput,
selection: TextSelection.collapsed(offset: newInput.length));
await tester.pumpAndSettle(throttleDuration);
expect(scrollController.position.pixels, initialScrollPosition);
});

testWidgets(
'shows cursor on screen when not scrollable with scroll parent',
(tester) async {
Expand Down