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

fix: side effects of itemscrollcontroller jumpto #1017

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,24 @@
);
}

final index = offset.toInt();
int index = max(0, offset.toInt());
final (start, end) = visibleRangeNotifier.value;
if (index < start || index > end) {
itemScrollController.jumpTo(
index: max(0, index),
alignment: 0.5,
);

if (start <= index && index <= end) {
return;
}

double alignment = 0.5;
if (index == 0) {
alignment = 0.0;
} else if (index == editorState.document.root.children.length - 1) {

Check warning on line 203 in lib/src/editor/editor_component/service/scroll/editor_scroll_controller.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/editor_component/service/scroll/editor_scroll_controller.dart#L203

Added line #L203 was not covered by tests
alignment = 1.0;
}

itemScrollController.jumpTo(
index: index,
alignment: alignment,
);
}

void jumpToTop() {
Expand Down
Loading