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(select): filter break bug #756

Merged
merged 5 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Pending

### Fixes

- Fix `n-select` filterable select breaks, closes [#510](https://github.com/TuSimple/naive-ui/issues/510).

## 2.16.0 (2021-08-02)

### Breaking Changes
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Pending

### Fixes

- 修复 `n-select` 可过滤的选择器失效,关闭 [#510](https://github.com/TuSimple/naive-ui/issues/510)

## 2.16.0 (2021-08-02)

### Breaking Changes
Expand Down
2 changes: 2 additions & 0 deletions src/_internal/selection/src/Selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default defineComponent({
onKeyup: Function as PropType<(e: KeyboardEvent) => void>,
onKeydown: Function as PropType<(e: KeyboardEvent) => void>,
onClick: Function as PropType<(e: MouseEvent) => void>,
onMousedown: Function as PropType<(e: MouseEvent) => void>,
onBlur: Function as PropType<(e: FocusEvent) => void>,
onFocus: Function as PropType<(e: FocusEvent) => void>,
onDeleteOption: Function,
Expand Down Expand Up @@ -209,6 +210,7 @@ export default defineComponent({
hoverRef.value = false
}
function handleMouseDown (e: MouseEvent): void {
props.onMousedown?.(e)
Copy link
Collaborator

Choose a reason for hiding this comment

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

不是每一个 mousedown 都要和 click 走一样的逻辑,这块的处理感觉不太行。

if (!props.active || !props.filterable) return
if (e.target === patternInputRef.value) return
e.preventDefault()
Expand Down
2 changes: 1 addition & 1 deletion src/select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ export default defineComponent({
}
loading={this.loading}
focused={this.focused}
onClick={this.handleTriggerClick}
onMousedown={this.handleTriggerClick}
Copy link
Collaborator

Choose a reason for hiding this comment

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

这块处理不能这么简单,得理一下逻辑,mousedown 干的事和 click 应该是有一些区别的。

如果有必要的话需要重新分配一下。

Copy link
Collaborator

@07akioni 07akioni Aug 3, 2021

Choose a reason for hiding this comment

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

mousedown 可以触发 openMenu,focus 不能。

要注意各种 filter + multiple 的组合不要出问题,以及按 tab focus 的状态不要受影响。

onDeleteOption={this.handleToggleOption}
onPatternInput={this.handlePatternInput}
onClear={this.handleClear}
Expand Down