Skip to content

Commit

Permalink
fix: search no scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Sep 2, 2024
1 parent d15d83b commit 3f8ae43
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/OptionList/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface ColumnProps<OptionType extends DefaultOptionType = DefaultOptio
halfCheckedSet: Set<React.Key>;
loadingKeys: React.Key[];
isSelectable: (option: DefaultOptionType) => boolean;
searchValue?: string;
}

export default function Column<OptionType extends DefaultOptionType = DefaultOptionType>({
Expand All @@ -39,7 +38,6 @@ export default function Column<OptionType extends DefaultOptionType = DefaultOpt
halfCheckedSet,
loadingKeys,
isSelectable,
searchValue,
}: ColumnProps<OptionType>) {
const menuPrefixCls = `${prefixCls}-menu`;
const menuItemPrefixCls = `${prefixCls}-menu-item`;
Expand Down Expand Up @@ -117,7 +115,7 @@ export default function Column<OptionType extends DefaultOptionType = DefaultOpt
}) => {
// >>>>> Open
const triggerOpenPath = () => {
if (disabled || searchValue) {
if (disabled) {
return;
}
const nextValueCells = [...fullPath];
Expand Down
4 changes: 2 additions & 2 deletions src/OptionList/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((

// >>>>> 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);
Expand All @@ -176,7 +177,7 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
scrollIntoParentView(ele);
}
}
}, [activeValueCells]);
}, [activeValueCells, searchValue]);

// ========================== Render ==========================
// >>>>> Empty
Expand Down Expand Up @@ -213,7 +214,6 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
<Column
key={index}
{...columnProps}
searchValue={searchValue}
prefixCls={mergedPrefixCls}
options={col.options}
prevValuePath={prevValuePath}
Expand Down

0 comments on commit 3f8ae43

Please sign in to comment.