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
Implementation of EditableTextState._scheduleShowCaretOnScreen
#104500
Comments
EditableTextState._scheduleShowCaretOnScreen
Hi @Oleksa5, Thanks for filing the issue.
Could you please share a minimal code sample which shows that this behavior is currently not possible, along with the output of |
import 'package:flutter/material.dart';
void main() {
const kPadding = 16.0;
final entry = ColoredBox(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(kPadding),
child: TextField(
controller: TextEditingController(
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis fermentum in dolor ut ullamcorper. Quisque ac nunc facilisis, accumsan orci vel, dictum dui. Cras nec eleifend mauris. Aliquam erat volutpat. Proin orci neque, convallis at justo eget, lacinia porta tellus. Suspendisse euismod ipsum risus. Quisque cursus vitae diam at venenatis. Quisque interdum maximus dui. Aenean ac turpis risus. Donec sed augue imperdiet, finibus dui ut, ullamcorper orci. Nulla placerat augue id lectus pulvinar, eu sollicitudin ex viverra. Cras pulvinar gravida est at laoreet. Phasellus accumsan tortor vel eros fermentum, eget fringilla leo commodo. Sed ut ligula fermentum, vestibulum ipsum id, suscipit justo. Cras rhoncus gravida pulvinar. Phasellus lectus lorem, ultrices in ornare at, commodo non eros. Phasellus imperdiet malesuada aliquet. Etiam mi turpis, tincidunt a commodo a, accumsan ut nibh. Praesent eleifend sagittis ornare. Pellentesque a dui nec velit mollis pulvinar. Quisque ut tincidunt turpis, at ultricies justo. Ut commodo nibh a lectus laoreet, id congue turpis placerat. Sed nec tellus suscipit, congue tortor non, sodales urna. Praesent vehicula purus imperdiet bibendum condimentum. Proin mauris diam, feugiat laoreet sagittis ac, mattis quis justo. Morbi eu nisl sem. Phasellus sit amet pharetra dui, in accumsan risus. Cras egestas elementum quam feugiat feugiat. Aenean aliquet porta orci tempus ullamcorper. Pellentesque pulvinar sit amet nunc vel ornare. Donec sollicitudin, ex ut efficitur accumsan, odio nisi pellentesque orci, eu pellentesque diam nunc sed ex. Fusce commodo leo eu imperdiet ornare. Nam id volutpat nulla, nec tincidunt risus. Nunc interdum porta nibh, ut maximus velit pulvinar vel. Nunc vel eros est. Nunc non vestibulum lacus. Donec malesuada ultrices ultricies. Cras tempus dui mauris. Sed vehicula tincidunt molestie. Suspendisse pretium semper gravida. Etiam mollis mi gravida hendrerit feugiat. Curabitur eget auctor velit. Nullam ultrices, nunc ullamcorper fringilla interdum, elit erat venenatis lectus, molestie rutrum enim purus ac tellus. Cras lacinia est id mi facilisis, aliquam rutrum neque dignissim. Aliquam vitae eros mauris. Nam et ornare risus. Nam mollis lacinia sapien vitae rhoncus. Curabitur bibendum felis felis, id hendrerit metus cursus quis. Sed dignissim sem vitae scelerisque elementum. Etiam nec felis in risus bibendum aliquet nec in urna. Maecenas lacinia est quis malesuada ullamcorper. Sed blandit venenatis justo in ultrices. Donec euismod massa eget aliquam molestie. Donec at ipsum at justo feugiat tempor in ac nisl. Morbi a turpis est. Cras pretium varius nisl malesuada dapibus. Nulla facilisi. Proin lectus lorem, convallis vel blandit quis, ullamcorper id ex. Integer semper ante nec nisi dictum molestie ut nec velit. Phasellus vulputate eu ipsum nec suscipit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Maecenas aliquet efficitur felis, et accumsan tortor suscipit sit amet. Fusce accumsan rhoncus sapien, at pellentesque ligula."
),
style: const TextStyle(
color: Colors.black87
),
maxLines: null
),
),
);
runApp(
MaterialApp(
darkTheme: ThemeData.dark(),
themeMode: ThemeMode.dark,
home: Material(
child: ListView(
padding: const EdgeInsets.all(kPadding),
children: [
entry,
const SizedBox(height: kPadding),
entry
]
),
),
)
);
} Note that the second entry is not necessary to reveal the issue. Doctor summary:
|
The suggested solution only works for selecting by dragging mouse, but not by moving handles. So there should probably be more profound changes to make scrolling selection works with handles as well.
One solution would be to add As for |
I agree that the root problem is probably the same. I'll take another look at a solution in #102992. |
After investigating, I think my solution in #102992 of using Scrollable.of to compensate for the outer scrollable isn't enough. It will still be blocked by the problem detailed in this issue. If I try it without addressing this issue, I get this kind of bounce: Screen.Recording.2022-05-27.at.4.04.46.PM.movInterestingly, I didn't see that bounce until I merged in master. So commit bd37072 didn't bounce and worked fine without considering this issue. Something must have changed in the last ~3 weeks. Either way now, I think my PR will need to address both issues. |
#102992 will merge shortly, and with my testing it seems to fix this issue on desktop but not on mobile. |
Didn't mean to close this, we should figure out what the problem is on mobile. |
Currently it's not possible to select more text than it's visible in a scrollable. Because the function is always trying to show a padded caret rect, which for selected text happens to be at the beginning of the selection. This is because
_FloatingCursorPainter.paint
skips painting for non-collapsed selection and updating the cashed caret rect is performed at the end of the painting via callback toRenderEditable
.Visually there is no caret on non-collapsed selection, then what to show? Why should the beginning of the selection be treated as the caret position and not the end? Maybe the function should have another name and
EditableTextState._currentCaretRect
be updated tonull
. Or_currentCaretRect
should be updated even for non-collapsed selection and placed at the extent of the selection.Probably the simplest solution would be to add
and change
to
Also note there is another issue with scrolling while selecting text by dragging the mouse, but that has to do with the implementation of
TextSelectionGestureDetectorBuilder.onDragSelectionUpdate
.The text was updated successfully, but these errors were encountered: