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):[select] fix the focus event is triggered and prevent the panel from failing to collapse #2876

Merged
merged 2 commits into from
Feb 11, 2025
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
11 changes: 6 additions & 5 deletions packages/renderless/src/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,16 +894,17 @@ export const initValue =
}

export const setSoftFocus =
({ vm, state }) =>
({ vm, state, props }) =>
() => {
state.softFocus = true

const input = vm.$refs.input || vm.$refs.reference

if (input) {
input.focus()
// tiny 新增: 解决获焦即弹出时,关闭不了下拉面板,所以增加了!props.automaticDropdown条件
if (!props.automaticDropdown) {

Choose a reason for hiding this comment

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

确保props.automaticDropdown的正确性和完整性,以避免潜在的逻辑错误。

if (input) {
input.focus()
}
}

// tiny 新增: 解决 reference 插槽时,选择数据后,需要点2次才能打开下拉面板
state.softFocus = false
}
Expand Down
2 changes: 1 addition & 1 deletion packages/renderless/src/select/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ const initApi = ({
toggleMenu: toggleMenu({ vm, state, props, api, isMobileFirstMode }),
showTip: showTip({ props, state, vm }),
onOptionDestroy: onOptionDestroy(state),
setSoftFocus: setSoftFocus({ vm, state }),
setSoftFocus: setSoftFocus({ vm, state, props }),
getcheckedData: getcheckedData({ props, state }),
resetInputWidth: resetInputWidth({ vm, state }),
resetHoverIndex: resetHoverIndex({ props, state }),
Expand Down
Loading