Skip to content

Commit

Permalink
Merge branch 'release/T25.imp' of github.com:the-events-calendar/trib…
Browse files Browse the repository at this point in the history
…e-common into fix/TEC-5086_deprecated_notice
  • Loading branch information
pattihis committed Jan 6, 2025
2 parents ee29544 + 3b6d19f commit 6cb5f39
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 34 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-FBAR-330-tabindex-search
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Improves accessibility of select2 component, allowing tabbing into elements.
10 changes: 5 additions & 5 deletions tests/wpunit/Tribe/JSON_LD/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function it_should_return_array_with_one_post_in_it_if_trying_to_get_data

$user = $this->factory()->user->create( [ 'role' => 'administrator' ] );
wp_set_current_user( $user );

$sut = $this->make_instance();
$data = $sut->get_data( $post );
$this->assertInternalType( 'array', $data );
Expand Down Expand Up @@ -167,12 +167,12 @@ public function should_show_json_ld_information_to_visitors(): void {
);

$this->assertFalse(
current_user_can( 'read', $post_id ),
current_user_can( 'read_post', $post_id ),
'A visitor user will not have the read capability for posts.'
);

$this->assertFalse(
current_user_can( 'read', $event->ID ),
current_user_can( 'read_post', $event->ID ),
'A visitor user will not have the read capability for events.'
);

Expand Down Expand Up @@ -248,12 +248,12 @@ public function should_show_json_ld_information_to_subscribers(): void {
);

$this->assertTrue(
current_user_can( 'read', $post_id ),
current_user_can( 'read_post', $post_id ),
'A subscriber user will have the read capability for posts.'
);

$this->assertTrue(
current_user_can( 'read', $event->ID ),
current_user_can( 'read_post', $event->ID ),
'A subscriber user will have the read capability for events.'
);

Expand Down
43 changes: 23 additions & 20 deletions vendor/tribe-selectWoo/dist/js/selectWoo.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ S2.define('select2/results',[

Results.prototype.render = function () {
var $results = $(
'<ul class="select2-results__options" role="listbox" tabindex="-1"></ul>'
'<ul class="select2-results__options" role="listbox"></ul>'
);

if (this.options.get('multiple')) {
Expand Down Expand Up @@ -958,7 +958,7 @@ S2.define('select2/results',[
var attrs = {
'role': 'option',
'data-selected': 'false',
'tabindex': -1
'tabindex':'0',
};

if (data.disabled) {
Expand Down Expand Up @@ -988,10 +988,17 @@ S2.define('select2/results',[

option.setAttribute(attr, val);
}
var $option = $(option);

if (data.children) {
var $option = $(option);
$option.on( 'blur', function() {
$option.attr( 'data-selected', 'false' );
});

$option.on( 'focus', function() {
$option.attr( 'data-selected', 'true' );
});

if (data.children) {
var label = document.createElement('strong');
label.className = 'select2-results__group';

Expand Down Expand Up @@ -1040,7 +1047,6 @@ S2.define('select2/results',[

if (container.isOpen()) {
self.setClasses();
self.highlightFirstItem();
}
});

Expand Down Expand Up @@ -1875,7 +1881,7 @@ S2.define('select2/selection/allowClear',[
}
}

// Allow clearing when the data-placeholder attribute isn't set.
// Allow clearing when the data-placeholder attribute isn't set.
if ( typeof this.placeholder !== 'undefined' ) {
this.$element.val( this.placeholder.id ).trigger( 'change' );
} else {
Expand Down Expand Up @@ -1928,7 +1934,7 @@ S2.define('select2/selection/search',[
Search.prototype.render = function (decorated) {
var $search = $(
'<li class="select2-search select2-search--inline">' +
'<input class="select2-search__field" type="text" tabindex="-1"' +
'<input class="select2-search__field" type="text"' +
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
'</li>'
Expand Down Expand Up @@ -2079,7 +2085,6 @@ S2.define('select2/selection/search',[
* @private
*/
Search.prototype._transferTabIndex = function (decorated) {
this.$search.attr('tabindex', this.$selection.attr('tabindex'));
this.$selection.attr('tabindex', '-1');
};

Expand Down Expand Up @@ -3697,9 +3702,9 @@ S2.define('select2/data/tags',[
};

Tags.prototype.createTag = function (decorated, params) {
if ( 'string' !== typeof params.term ) {
return null;
}
if ( 'string' !== typeof params.term ) {
return null;
}

var term = params.term.trim();

Expand Down Expand Up @@ -3991,16 +3996,16 @@ S2.define('select2/dropdown',[

S2.define('select2/dropdown/search',[
'jquery',
'../utils'
], function ($, Utils) {
'../keys'
], function ($, KEYS) {
function Search () { }

Search.prototype.render = function (decorated) {
var $rendered = decorated.call(this);

var $search = $(
'<span class="select2-search select2-search--dropdown">' +
'<input class="select2-search__field" type="text" tabindex="-1"' +
'<input class="select2-search__field" type="text"' +
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
' spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="true" />' +
'</span>'
Expand Down Expand Up @@ -4035,21 +4040,19 @@ S2.define('select2/dropdown/search',[
});

this.$search.on('keyup input', function (evt) {
var key = evt.which;
if (key === KEYS.TAB) {
return;
}
self.handleSearch(evt);
});

container.on('open', function () {
self.$search.attr('tabindex', 0);
self.$search.attr('aria-owns', resultsId);
self.$search.trigger( 'focus' );

window.setTimeout(function () {
self.$search.trigger( 'focus' );
}, 0);
});

container.on('close', function () {
self.$search.attr('tabindex', -1);
self.$search.removeAttr('aria-activedescendant');
self.$search.removeAttr('aria-owns');
self.$search.val('');
Expand Down
23 changes: 14 additions & 9 deletions vendor/tribe-selectWoo/dist/js/selectWoo.full.min.js

Large diffs are not rendered by default.

0 comments on commit 6cb5f39

Please sign in to comment.