Select2 adds title attribute to form controls

I am using Select2 version 3.4.8 and recently noticed that the code adds a title attribute to each form control on my page, using the associated label text for the title . I assume that the developers of Select2 meant it as an improvement in accessibility, but this is a dubious choice, since there is already a related label .

I am looking for a way to disable this without fixing select2.js directly. I looked through the documentation and found nothing. Is there a way to do this, or do I need to either schedule select2.js (maybe comment line 692) or write some script lines to remove the title attributes after they have been added to the .select2-container divs? (Or is it fixed in version 3.5.0?)

+6
source share
2 answers

When loading the page, add the following script:

$ ("Select2-selection__rendered") removeAttr ('name') ;.

This will remove the header.

+1
source

The title attribute is useless here, but also harmless. It applies to an off-screen version of an element with tabindex="-1" . An element with tabindex="-1" cannot receive keyboard focus by default, and this will never be declared by assistive technology (unless focus is explicitly specified with javascript).

Only the associated tag will be announced. I tested this behavior with VoiceOver / Chrome.

0
source

Source: https://habr.com/ru/post/972660/


All Articles