signavio / react-mentions

@mention people in a textarea
https://react-mentions.vercel.app
Other
2.42k stars 566 forks source link

When using the arrow up/down to navigate through the suggestion list, automatic scrolling up/down is not available. #653

Closed owlran closed 1 year ago

owlran commented 1 year ago

Steps to reproduce:

  1. add max-height and overflow-y: auto to suggestions list
  2. use @ to call suggestion list
  3. If you continue to use arrow down to move further down, you will see the focused item gradually moving down, but it won't automatically scroll to the focused item.

Expected behaviour: To automatically scroll to the position of the focused item.

Observed behaviour: Currently, there is no automatic scrolling down to the focused item.

react-mentions-issue

codesandbox

Workaround: It was found that this problem occurred when the suggestionOverlay was refactored into a hook. see this commit Originally, the scroll position would be updated in componentDidUpdate, but in the hook version, it only does this in the initial effect.

work fine in the version of react-mentions at 4.4.6. -> codesandbox This version is prior to the suggesionsOverlay refactor react hook, which causes the suggestion list to not scroll automatically when using the up and down arrow keys to scroll.