searchDelay being implemented as a throttle rather than a debounce is bad for accessibility

searchDelay being implemented as a throttle rather than a debounce is bad for accessibility

coredumperrorcoredumperror Posts: 2Questions: 0Answers: 0

I'm currently working on making my team's websites more accessible, and today my task has been making our DataTables work better for users of screen readers. I've got it pretty much right, but there's one major sticking point that's really bothering me.

As mentioned on this old post from this forum, the searchDelay functionality has been intentionally implemented as a throttle, rather than a debounce. This means that as soon as the user types a single character in the search box, a search is performed, and another search is not performed until searchDelay number of milliseconds has passed.

The problem with this implementation is that even if you set a searchDelay of, say, 750 milliseconds, the "info" panel gets updated at least twice for a single search: once before the search terms have been fully written, once after the throttle time, and if the user is still typing after that, even more readings will occur.

This gets to be quite annoying when the contents of the info panel are e.g. "Showing 1 to 50 of 68 records. (filtered from 1,449 total entries)". And because its aria-live="polite", the ENTIRE contents of that info panel get read out without interruption, then they get read out again once it's updated after the first throttle delay, and potentially multiple additional times if it took longer for the user to type their search than the throttle delay. And for screen-reader users who are perhaps less adept with keyboards than the average user, this is fairly likely.

This is why a debounce implementation is superior for accessibility. The table and the info panel will only be updated a single time: after the user has stopped typing for longer than searchDelay number of milliseconds.

I've implemented the workaround that converts the throttle to a debounce from that thread I linked above, and it works great! I'm hoping you can implement debounce-based search functionality as at least an option, if not the default, in a future version of DataTables.

Replies

  • allanallan Posts: 62,990Questions: 1Answers: 10,367 Site admin

    The plan is to change this for DataTables 2. I can't recall if I've already made that commit or not. Will look out up and greet back to you over the weekend.

    Allan

  • allanallan Posts: 62,990Questions: 1Answers: 10,367 Site admin

    Yup confirmed this - it uses a debounce rather than a throttle in DT2.

    Allan

  • coredumperrorcoredumperror Posts: 2Questions: 0Answers: 0

    That's great! Any sort of ETA on the release of DT2?

  • allanallan Posts: 62,990Questions: 1Answers: 10,367 Site admin

    Expected this month :)

    Allan

Sign In or Register to comment.