React - Menu - How to close the menu button when clicking a random place on the page with openOnClick

1 Answer 79 Views
Menu
Jason
Top achievements
Rank 2
Iron
Iron
Iron
Jason asked on 03 Oct 2023, 05:38 PM

Greetings,

I'm trying to implement the menu buttons that will only expand when it's clicked and it should remain open when the mouse pointer leaves the Menu. Currently, the user has to click the menu button or the items to close the menu. Is there a way to close the menu and disable the open-on-hover behavior by clicking outside of the menu button on the page?

Here is the snippet of the code:

<Menu
  openOnClick
  hoverCloseDelay={100000}
>

Please help, thanks!

 

Jason

1 Answer, 1 is accepted

Sort by
1
Konstantin Dikov
Telerik team
answered on 04 Oct 2023, 02:04 PM

Hello Jason,

Although that there is no configuration that can be used for achieving the desired result, you can handle the "click" event of the document and close the menu manually if the target of the click event is not within the menu or its popup. Following is an example demonstrating this approach:

Hope this helps.

 

Regards,
Konstantin Dikov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!

Jason
Top achievements
Rank 2
Iron
Iron
Iron
commented on 04 Oct 2023, 02:40 PM

Hi Konstantin,

Is there a way to disable the open-on-hover functionality after closing the menu by clicking outside of the menu?

Thanks for your help!

 

Jason

Konstantin Dikov
Telerik team
commented on 05 Oct 2023, 06:07 AM

Hi,

Currently the openOnClick will be applied for the initial open of the Menu and afterwards it will be open on hover. We have logged item for introducing another option that will open the menu on click all the time:

I have included this request as well to increase its priority and I will also try to forward it to the team and see if we can add it in the planning for the next releases.

Tags
Menu
Asked by
Jason
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Konstantin Dikov
Telerik team
Share this question
or