Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-22492: Livedata filter options are misread #3700

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ define('xwiki-selectize', [
'xwiki-events-bridge'
], function($, Selectize, l10n) {
var optionTemplate = [
'<div class="xwiki-selectize-option" data-value="">',
'<div class="xwiki-selectize-option" role="option" aria-selected="false" data-value="">',
'<span class="xwiki-selectize-option-icon"></span>',
'<span class="xwiki-selectize-option-label"></span>',
'</div>'
@@ -203,6 +203,25 @@ define('xwiki-selectize', [
});
}
}
let oldOnOptionSelect = this.selectize.onOptionSelect;
this.selectize.onOptionSelect = function(...args) {
const result = oldOnOptionSelect.apply(this, args);
// clear aria-selected state on all previously selected elements first
this.get$('dropdown').find('.option').attr('aria-selected','false');
// then set the aria-selected state of the newly selected element.
this.get$('dropdown').find('.selected').attr('aria-selected','true');
Sereza7 marked this conversation as resolved.
Show resolved Hide resolved
return result;
}
let oldSetActiveOption = this.selectize.setActiveOption;
this.selectize.setActiveOption = function(option, ...args) {
this.liveRegion?.text($(option).text());
oldSetActiveOption.call(this, option, ...args);
Sereza7 marked this conversation as resolved.
Show resolved Hide resolved
}
// Create a live region to store the value of the currently active option.
this.selectize.liveRegion = $('<span>');
this.selectize.liveRegion.attr('aria-live', 'assertive');
this.selectize.liveRegion.addClass('sr-only');
this.selectize.get$('input').after(this.selectize.liveRegion);
setDropDownAlignment(this.selectize);
if (this.selectize.settings.takeInputWidth) {
this.selectize.get$('control').width($(this).data('initialWidth'));