Topic: Treeview - do not affect keyboard?
Expected behavior If treeview present (in the modal) and cursor focused by clicking on some child, treeview should not catch all keyboard input. We open treeview in the modal and we would like to catch keydown for our custom driven closing modal by escape.
Actual behavior I am not able to catch keydown event, because treeview plugin stopped propagation and catch only for himself. It should be changed or it should be configrurable if current behavior is correct for you. It would be nice to be able to disable stopPropagation and leave keyboard input for user to do what we want.
meesha81 pro premium priority answered 2 years ago
Hi, I am not sure that you have jquery in snippet. But as you know, treeview can be controlled by arrows - expand/collapse, move across items. So it is clear that treeview catch keydown/keyup events. But all of them propably stopPropagation and/or preventDefault. So it is why it is blocking eg. Escape and keys useless for treeview, but with sense for other elements like modal as I described.
mlazaru staff commented 2 years ago
I see your point, thank you. I've added a task to take a closer look at it, including checking how it works in other components.
meesha81 pro premium priority answered 2 years ago
It is definitely because of wrong behavior of treeview. If you find in treeview.min.js this part:
{key:"_handleKeyboardNavigation",value:function(t,e){var n=t.keyCode;if(t.stopPropagation(),9!==n)switch(t.preventDefault(),n)
and chage it blindly to:
{key:"_handleKeyboardNavigation",value:function(t,e){var n=t.keyCode;if(null,9!==n)switch(t.preventDefault(),n)
Tree view stops preventDefault of some "keys". This is simple evidence, that treeview interferes to keyboard events a little too much.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.1.0
- Device: PC
- Browser: CHROME111
- OS: WIN11
- Provided sample code: No
- Provided link: No
mlazaru staff commented 2 years ago
Could you reproduce this problem in a snippet?