WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: [Web Component Development] How can I block the click event of the custom disabled elements?

for

From: Patrick H. Lauke
Date: Mar 16, 2021 4:42AM


On 16/03/2021 10:34, 박웅진 wrote:

> When the HTML native button is disabled, We can't activate it in any way.
> We tried a few ways to make the disabled custom button unclickable.

Presumably you have an actual function/handler hanging off of your
click? In that case, make the function itself check if the event target
that triggered the function is currently set to `aria-disabled`, and if
that's the case, bail out and don't execute whatever the function is
supposed to do?

function doIt(e) {
if (e.target.getAttribute('aria-disabled') == "true") {
return;
}
/* the actual thing that's supposed to happen on click */
}

P
--
Patrick H. Lauke

https://www.splintered.co.uk/ | https://github.com/patrickhlauke
https://flickr.com/photos/redux/ | https://www.deviantart.com/redux
twitter: @patrick_h_lauke | skype: patrick_h_lauke