-
Notifications
You must be signed in to change notification settings - Fork 245
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
[SuperTextField][SuperEditor] - Don't conflict with saved scroll offsets in page storage #2316
Comments
@matthew-carroll I was able to reproduce this issue with the following code in the example app: @override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: const [
Tab(text: 'Tab 1'),
Tab(text: 'Tab 2'),
Tab(text: 'Tab 3'),
],
),
),
body: TabBarView(
children: [
KeyedSubtree(
key: const PageStorageKey('page1'),
child: Column(children: [
Container(
width: double.infinity,
height: 300,
child: ExampleEditor(),
),
Expanded(
child: ListView.builder(
itemCount: 100,
itemBuilder: (context, index) => Text(index.toString()),
),
)
]),
),
Center(
child: Text('Tab 2'),
),
Center(
child: Text('Tab 3'),
),
],
),
),
); In this example, Screen.Recording.2024-09-16.at.22.50.39.movWe can fix this by using another Container(
width: double.infinity,
height: 300,
child: KeyedSubtree(
key: const PageStorageKey('editor'),
child: ExampleEditor(),
),
) With this change it works as expected: Screen.Recording.2024-09-16.at.22.55.08.movI'm not sure if we need to change anything in the editor/textfield. We cannot create a Flutter's textfield seems to work because it uses the /// {@template flutter.material.textfield.restorationId}
/// Restoration ID to save and restore the state of the text field.
///
/// If non-null, the text field will persist and restore its current scroll
/// offset and - if no [controller] has been provided - the content of the
/// text field. If a [controller] has been provided, it is the responsibility
/// of the owner of that controller to persist and restore it, e.g. by using
/// a [RestorableTextEditingController].
///
/// The state of this widget is persisted in a [RestorationBucket] claimed
/// from the surrounding [RestorationScope] using the provided restoration ID.
///
/// See also:
///
/// * [RestorationManager], which explains how state restoration works in
/// Flutter.
/// {@endtemplate}
final String? restorationId; So, even if we implement the interaction with the |
I have a few questions. First, do we currently expect scroll offsets to be maintained in @miguelcmedeiros - Do you guys currently retain scroll offsets in Next, what's the relevance of Lastly, if we decide we want to save and restore scroll offsets in |
A bug was found in a client app related to
SuperTextField
. I don't have a repro to paste here, but I found the following.Situation: A tab view with multiple pages. The first page of the tab view has a
SuperTextField
at the top of the page. Below theSuperTextField
is a list of items that can be scrolled up/down.Repro: On the page with the
SuperTextField
, scroll the list item of items down a bit. Switch to another tab page. Switch back to the tab page with theSuperTextField
. TheSuperTextField
now appears blank, because internally theSuperTextField
has scrolled itself.Root cause: Flutter seems to include code that automatically tries to load a scroll offset from
PageStorage
, and that automatic behavior is running withinSuperTextField
. I assume the reason we haven't seen this before is because we've never used aSuperTextField
within a situation that usedPageStorage
to store a scroll offset.The Flutter code that does this is within
ScrollPosition
, itself: https://github.com/flutter/flutter/blob/5d83a98331aca84d8489adda246c05c6084b058a/packages/flutter/lib/src/widgets/scroll_position.dart#L532Apparently, somehow, the built-in Flutter
TextField
doesn't have this problem. Perhaps Flutter'sTextField
added its ownPageStorage
? I haven't dug into it.In either event, we need to ensure that neither
SuperTextField
norSuperEditor
orSuperReader
apply someone else's scroll offset when being built, or rebuilt.The text was updated successfully, but these errors were encountered: