diff --git a/src/OptionList/Column.tsx b/src/OptionList/Column.tsx index 82ec25cb..5805ab1c 100644 --- a/src/OptionList/Column.tsx +++ b/src/OptionList/Column.tsx @@ -23,7 +23,6 @@ export interface ColumnProps; loadingKeys: React.Key[]; isSelectable: (option: DefaultOptionType) => boolean; - searchValue?: string; } export default function Column({ @@ -39,7 +38,6 @@ export default function Column) { const menuPrefixCls = `${prefixCls}-menu`; const menuItemPrefixCls = `${prefixCls}-menu-item`; @@ -117,7 +115,7 @@ export default function Column { // >>>>> Open const triggerOpenPath = () => { - if (disabled || searchValue) { + if (disabled) { return; } const nextValueCells = [...fullPath]; diff --git a/src/OptionList/List.tsx b/src/OptionList/List.tsx index 4beedd05..0850b016 100644 --- a/src/OptionList/List.tsx +++ b/src/OptionList/List.tsx @@ -166,6 +166,9 @@ const RawOptionList = React.forwardRef(( // >>>>> Active Scroll React.useEffect(() => { + if (searchValue) { + return; + } for (let i = 0; i < activeValueCells.length; i += 1) { const cellPath = activeValueCells.slice(0, i + 1); const cellKeyPath = toPathKey(cellPath); @@ -176,7 +179,7 @@ const RawOptionList = React.forwardRef(( scrollIntoParentView(ele); } } - }, [activeValueCells]); + }, [activeValueCells, searchValue]); // ========================== Render ========================== // >>>>> Empty @@ -213,7 +216,6 @@ const RawOptionList = React.forwardRef(( { let selectedValue: any; @@ -1022,6 +1022,85 @@ describe('Cascader.Basic', () => { wrapper.find(`li[data-path-key]`).at(0).simulate('click'); wrapper.find(`li[data-path-key]`).at(1).simulate('click'); }); + it('hover + search', () => { + let getOffesetTopTimes = 0; + const spyElement = spyElementPrototypes(HTMLElement, { + offsetTop: { + get: () => (getOffesetTopTimes++ % 2 === 0 ? 100 : 0), + }, + scrollTop: { + get: () => 0, + }, + offsetHeight: { + get: () => 10, + }, + }); + + const wrapper = render( + , + ); + fireEvent.change(wrapper.container.querySelector('input') as HTMLElement, { + target: { value: 'w' }, + }); + const items = wrapper.container.querySelectorAll('.rc-cascader-menu-item'); + fireEvent.mouseEnter(items[9]); + expect(mockScrollTo).toHaveBeenCalledTimes(0); + + spyElement.mockRestore(); + }); }); it('not crash when value type is not array', () => {