Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds implementation + tests. I can write the docs if you'd like them to be a part of the PR.
The purpose is to add a new scrolling mode called
smart
. We may make it default in v2 if we want.It behaves like
auto
when the target is within a single screen from the viewport boundaries, and behaves likecenter
otherwise. The rationale is that if something is far enough, there's no meaningful context to preserve — and therefore we might as well center it.In particular, centering is helpful for cases when the next selected item is relatively random (such as with "find by DOM node" picker in DevTools). In that case, the
auto
behavior often jumps between the top and the bottom selected nodes because we're not necessarily scrolling in any particular direction. However, thesmart
behavior tries to center things unless we're already pretty close to them.Before
After