Topic: Treeview - do not affect keyboard?

meesha81 priority asked 1 year ago

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.

Mateusz Lazaru staff commented 1 year ago

Could you reproduce this problem in a snippet?

meesha81 priority answered 1 year 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.

meesha81 priority answered 1 year 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.

Mateusz Lazaru staff commented 1 year 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.

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Priority
  • 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