How to prevent dropdown menu from closing when parent element display is none

2 Answers 430 Views
Button DropDownList Wrappers for React
Philip
Top achievements
Rank 1
Philip asked on 28 Jul 2021, 02:28 AM

How to prevent dropdown menu from closing when parent element display is none? For example, show on element hover. I have a div wrapper for Dropdownbutton which only shows dropdownbutton on wrapper hover. However, when dropdownbutton is clicked and you move the cursor to the popup menu it immediately close it.

<div className="hover-show">

    <DropDownButton ... />

</div>

#Dropdownbutton

2 Answers, 1 is accepted

Sort by
0
Ina
Telerik team
answered on 28 Jul 2021, 11:46 AM

Hello Philip,

I could not reproduce the issue. Could you please give us more information about your use case?

Perhaps steps to reproduce or Stackblitz code example could be great. That way we could be able to debug the issue and help further.

I assumed that you would like to control the opened state of the DropDownButton programmatically.

We have an open feature request about this behavior:

https://github.com/telerik/kendo-react/issues/1009 

The feature is already implemented and it is going to be released with the next KendoReact version.

We will add a comment with the version in which it is present.

Please let me know if I could help with something more.

Regards,
Ina
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Philip
Top achievements
Rank 1
commented on 28 Jul 2021, 04:06 PM | edited

https://stackblitz.com/edit/react-ts-rfznqa?file=index.tsx



Steps to reproduce:

Hover "hover me"
Click the dropdown button.
Hover the popup menu.
Popup menu closes immediately.
Could this may be event bubble or capture?
0
Ina
Telerik team
answered on 29 Jul 2021, 08:40 AM

Hello Philip,

Thank you for your code example.

I have modified it to achieve the behavior:

https://stackblitz.com/edit/react-ts-gh9pt8?file=index.tsx 

In this Stackblitz code, we are using the `PopupPropsContext`. It allows us to attach the Popup of the DropDownButton to an element of our choice. In this code, we are adding the ref to the outer `div` element and appending the `PopupPropsContext` context to it. 

For more information about the `PopupPropsContext` you can check the following link:

https://www.telerik.com/kendo-react-ui/components/popup/global-context/ 

You can also check and this API reference to the `PopupPropsContext`:

https://www.telerik.com/kendo-react-ui/components/popup/api/PopupPropsContext/ 

Please let me know if you need more assistance.

Regards,
Ina
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Button DropDownList Wrappers for React
Asked by
Philip
Top achievements
Rank 1
Answers by
Ina
Telerik team
Share this question
or