Skip to content

Commit

Permalink
Only scroll editor upon focus if element fits in viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jan 9, 2023
1 parent 6159f64 commit 2ea6fdc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class Quill {
[index, length, , source] = overload(index, length, source);
this.selection.setRange(new Range(Math.max(0, index), length), source);
if (source !== Emitter.sources.SILENT) {
this.selection.scrollIntoView(this.scrollingContainer);
this.scrollIntoView();
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions core/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,6 @@ class Selection {
if (range == null) return;
const bounds = this.getBounds(range.index, range.length);
if (bounds == null) return;
const limit = this.scroll.length() - 1;
const [first] = this.scroll.line(Math.min(range.index, limit));
let last = first;
if (range.length > 0) {
[last] = this.scroll.line(Math.min(range.index + range.length, limit));
}
if (first == null || last == null) return;
const scrollBounds = scrollingContainer.getBoundingClientRect();
if (bounds.top < scrollBounds.top) {
scrollingContainer.scrollTop -= scrollBounds.top - bounds.top;
Expand Down

0 comments on commit 2ea6fdc

Please sign in to comment.