javascriptangularmodal-dialogsimplemodal

Javascript event.preventDefault() not working on modal


I am working in Angular to implement accessibility and adding (keyup.space) events on clickable elements. Space press has a default behavior that moves the scrollbar, which I don't want to happen. I managed to skip it in the main page by using event.preventDefault(), but when I press space in a button in the modal the behavior is present although I use event.preventDefault().

Is there any way to stop the default behavior of moving the scrollbar when I press space in an element in the modal?


Solution

  • I was using (keyup.space)="$event.preventDefault();onClickMethod()" event. I fixed it by using (keydown.space)=="$event.preventDefault();onClickMethod()"