Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pro:search): select panel virtual not working #1501

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/pro/search/docs/Api.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ SelectSearchFieldConfig
| `separator` | 多选分隔符 | `string` | `'|'` | - | - |
| `showSelectAll` | 是否支持全选 | `boolean` | `true` | - | - |
| `virtual` | 是否支持虚拟滚动 | `boolean` | `false` | - | 默认不支持 |
| `overlayItemWidth` | 选项宽度 | `number` | - | - | - |
| `onSearch` | 搜索回调函数 | `(searchValue: string) => void | ((searchValue: string) => void)[]` | - | - | 在触发搜索值改变时执行 |

> 注:使用 `Ctrl + Enter` 在多选下切换面板中选项选中状态
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code review

  1. The separator and showSelectAll properties of the SelectSearchFieldConfig are not necessary to be passed as parameters, as they have default values already.

  2. The overlayItemWidth property is not required as it is optional.

  3. The onSearch property should have a more descriptive name, such as onSearchValueChange, as it is used to indicate when the search value has changed.

  4. The comment at the end should be more descriptive, such as 'Use Ctrl+Enter to toggle the selection of items in the multi-select panel'

Expand Down
1 change: 1 addition & 0 deletions packages/pro/search/src/panel/SelectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export default defineComponent({
getKey: 'key',
labelKey: 'label',
selectedKeys: props.value,
virtual: props.virtual,
onOptionClick: handleOptionClick,
'onUpdate:activeValue': setActiveValue,
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review:

The code looks good and seems to be doing what it is supposed to do. There are no obvious bugs or potential risks that I can see. However I would suggest adding some comments to the code to help explain why the line was added and what it does. This will make it easier for you or anyone else to go back and understand the code at a later stage.

Expand Down
1 change: 0 additions & 1 deletion packages/pro/search/src/types/searchFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export interface SelectSearchField extends SearchFieldBase<VKey | VKey[]> {
virtual?: boolean
searchFn?: (data: SelectPanelData, searchText?: string) => boolean
onSearch?: MaybeArray<(searchValue: string) => void>
overlayItemWidth?: number
}
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with reviewing the code patch

The code patch looks good to me overall. The only issue I can see is the removal of the "overlayItemWidth" property. This may have an impact on the user experience if it is used in a specific context. I would suggest adding this back in or replacing it with an alternative that provides a similar function. Additionally, I would suggest adding some comments to explain why the changes were made and how they are beneficial.

Expand Down