# Autocomplete Scroll Behavior

**URL:** <https://discuss.codemirror.net/t/autocomplete-scroll-behavior/8427>\
**Category:** Lezer\
**Created:** [July 4, 2024, 12:00am UTC](https://discuss.codemirror.net/t/autocomplete-scroll-behavior/8427 "2024-07-04T00:00:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blh](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/blh/32/4521_2.png) [@blh](https://discuss.codemirror.net/u/blh)\
**Post date:** [July 4, 2024, 12:00am UTC](https://discuss.codemirror.net/t/autocomplete-scroll-behavior/8427/1 "2024-07-04T00:00:27Z")

</div>

Is there a way to customize the scroll behavior of autocomplete?

Right now, `scrollIntoView` has a custom implementation.

> <https://github.com/codemirror/autocomplete/blob/2ef51c4697a817aaffb24604c81127c4eef7abd0/src/tooltip.ts#L298-L304>

I wonder if this can be replaced with the native method

> **[Element: scrollIntoView() method - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)**
>
> The Element interface's
> scrollIntoView() method scrolls the element's ancestor
> containers such that the element on which scrollIntoView() is called is
> visible to the user.

and then its parameters be available as options passed into the autocompletion extension.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [July 4, 2024, 7:39am UTC](https://discuss.codemirror.net/t/autocomplete-scroll-behavior/8427/2 "2024-07-04T07:39:21Z")

</div>

Why do you need this?

---

<div class="post-metadata">

**Author:** ![blh](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/blh/32/4521_2.png) [@blh](https://discuss.codemirror.net/u/blh)\
**Post date:** [July 4, 2024, 8:17am UTC](https://discuss.codemirror.net/t/autocomplete-scroll-behavior/8427/3 "2024-07-04T08:17:46Z")

</div>

I styled the autocomplete to have margin around the list items. Normally with browser `scrollIntoView`, you can align the scroll with `scrollMargin` so the margin isn’t cutoff.

But with the custom `scrollIntoView` implementation, it doesn’t account for that. I would also want smoothScrolling as an option.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [July 8, 2024, 9:58am UTC](https://discuss.codemirror.net/t/autocomplete-scroll-behavior/8427/4 "2024-07-08T09:58:54Z")

</div>

Frankly, this feels too specific to add a library feature for, I’m sorry.
