Skip to content

The drop-down box will disappear when using a-input to get the focus in the a-select component custom menu dropdownRender #6133

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

Closed
1 task
HavocZhang opened this issue Dec 2, 2022 · 5 comments
Labels

Comments

@HavocZhang
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.2.14

Environment

windows,所有浏览器

Reproduction link

https://www.antdv.com/components/select-cn/#components-select-demo-custom-dropdown

Steps to reproduce

在a-select组件自定义菜单dropdownRender中使用a-input获取焦点时下拉框会消失,如果使用@mousedown="e => e.preventDefault()"又无法获取a-input焦点

What is expected?

看了ant.design5.0.3希望能做到和这里面扩展菜单一样的样例
https://stackblitz.com/run?file=demo.js

What is actually happening?

看了之前提的这个问题,都没有解决

@github-actions github-actions bot changed the title 在a-select组件自定义菜单dropdownRender中使用a-input获取焦点时下拉框会消失 The drop-down box will disappear when using a-input to get the focus in the a-select component custom menu dropdownRender Dec 2, 2022
@github-actions
Copy link

github-actions bot commented Feb 1, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Feb 1, 2023
@github-actions github-actions bot closed this as completed Feb 9, 2023
@HavocZhang
Copy link
Author

一直没人解决

@cereschen
Copy link

cereschen commented May 9, 2023

传递 open 监听 onDropdownVisibleChange 手动控制下拉框的显示
设置个属性 disableOpen来禁止关闭

                  onDropdownVisibleChange={(val) => {
                    if (!disableOpen.value) {
                      open.value = val
                    }
                  }}

在不想要关闭的地方

    onMousedown={(e) => {
                      disableOpen.value = true
                      setTimeout(() => {
                        disableOpen.value = false
                      }, 200)
                    }}

@RosApr
Copy link

RosApr commented May 10, 2023

我们可以通过判断当前鼠标操作的元素是否为该组件内的元素或者是列表内的元素来控制select dropdown的展示隐藏

demo
https://stackblitz.com/edit/vitejs-vite-7euxnh
欢迎交流指正

@AKclown
Copy link

AKclown commented Apr 29, 2024

onMousedown

感谢可以的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants