问题是当提及列表弹出窗口有滚动时,keydown/keyup不起作用,我可以用鼠标滚动,但是keyup/keydown不能使滚动移动到正确的位置
发布于 2020-12-16 14:12:22
这可以通过自定义入口组件->来实现
const entryComponent = (props:any) => {
const { mention, isFocused, searchValue, ...parentProps } = props;
const entryRef = React.useRef<HTMLDivElement>(null);
useEffect(() => {
if (isFocused) {
if (entryRef.current && entryRef.current.parentElement) {
entryRef.current.scrollIntoView({
block: 'nearest',
inline: 'center',
behavior: 'auto'
});
}}
}, [isFocused]);
return (
<>
<div
ref={entryRef}
role='option'
aria-selected={(isFocused ? 'true' : 'false')}
{...parentProps}>
<div className={'mentionStyle'}>
{mention.name}
</div>
</div>
</> );
};https://stackoverflow.com/questions/61932868
复制相似问题