MDL-78885 aria: Add support for data-short-text

This commit is contained in:
Shamim Rezaie 2023-10-31 22:20:31 +11:00
parent 7fa36e6bf0
commit a320dff736
6 changed files with 14 additions and 6 deletions

View File

@ -27,7 +27,7 @@
"name": "Foo bar"
}
}}
<li id="result-{{id}}" class="w-100 dropdown-item d-flex px-0 align-items-center" role="option" data-value="{{id}}" aria-label="{{$arialabel}}{{#str}}viewresults, core, {{name}}{{/str}}{{/arialabel}}">
<li id="result-{{id}}" class="w-100 dropdown-item d-flex px-0 align-items-center" role="option" data-short-text="{{$shorttext}}{{/shorttext}}" data-value="{{id}}" aria-label="{{$arialabel}}{{#str}}viewresults, core, {{name}}{{/str}}{{/arialabel}}">
{{$content}}
<span class="d-block w-100 px-2 text-truncate">
{{name}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -378,9 +378,9 @@ const comboboxFix = () => {
}
if (combobox.hasAttribute('value')) {
combobox.value = option.textContent.replace(/[\n\r]+|[\s]{2,}/g, ' ').trim();
combobox.value = option.dataset.shortText || option.textContent.replace(/[\n\r]+|[\s]{2,}/g, ' ').trim();
} else {
combobox.textContent = option.textContent;
combobox.textContent = option.dataset.shortText || option.textContent;
}
if (combobox.dataset.inputElement) {

View File

@ -34,6 +34,7 @@
}}
{{<core/local/comboboxsearch/resultitem }}
{{$arialabel}}{{#str}}viewresults, core, {{fullname}}{{/str}}{{/arialabel}}
{{$shorttext}}{{fullname}}{{/shorttext}}
{{$content}}
<span class="d-block px-2 w-25">
{{#profileimageurl}}

View File

@ -57,7 +57,14 @@
{{/results}}
{{$selectall}}
{{#selectall}}
<li id="result-row-0" class="w-100 p-1 border-top bottom-0 position-sticky dropdown-item d-flex small p-3" role="option" data-value="0">
<li
id="result-row-0"
class="w-100 p-1 border-top bottom-0 position-sticky dropdown-item d-flex small p-3"
role="option"
{{! The data-short-text attribute is provided so that aria.js would use it rather than the whole content. }}
data-short-text="{{searchterm}}"
data-value="0"
>
{{#str}}viewallresults, core, {{matches}}{{/str}}
</li>
{{/selectall}}