mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-17 04:47:10 +09:00
fix: fix missing accessible name on static Fomantic combobox dropdowns (#40163)
Fixes https://github.com/go-gitea/gitea/issues/40107 Static Fomantic dropdowns get `role="combobox"` or `role="menu"`, and neither role takes its accessible name from child contents (`nameFrom: author` only). Dropdowns like Filter and Sort on `/explore/repos` without `data-tooltip-content`, `aria-label` or `aria-labelledby` therefore had an empty accessible name. If the focusable element still has no `aria-label` or `aria-labelledby` after the tooltip check, link `aria-labelledby` to the dropdown's direct `.text` or `span` child. Selection dropdowns are skipped because their `.text` holds the current value, not a label. --------- Co-authored-by: Mark <14371969+malfunctionAI@users.noreply.github.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
2 files changed
+12
No files matched your search
@@ -4,14 +4,18 @@ test('explore repositories', async ({page}) => {
|
||||
await page.goto('/explore/repos');
|
||||
await expect(page.getByPlaceholder('Search repos…')).toBeVisible();
|
||||
await expect(page.getByRole('link', {name: 'Repositories'})).toBeVisible();
|
||||
await expect(page.getByLabel('Filter', {exact: true})).toBeVisible();
|
||||
await expect(page.getByLabel('Sort', {exact: true})).toBeVisible();
|
||||
});
|
||||
|
||||
test('explore users', async ({page}) => {
|
||||
await page.goto('/explore/users');
|
||||
await expect(page.getByPlaceholder('Search users…')).toBeVisible();
|
||||
await expect(page.getByLabel('Sort', {exact: true})).toBeVisible();
|
||||
});
|
||||
|
||||
test('explore organizations', async ({page}) => {
|
||||
await page.goto('/explore/organizations');
|
||||
await expect(page.getByPlaceholder('Search orgs…')).toBeVisible();
|
||||
await expect(page.getByLabel('Sort', {exact: true})).toBeVisible();
|
||||
});
|
||||
@@ -167,6 +167,14 @@ function attachStaticElements(dropdown: AriaDropdownElement, focusable: HTMLElem
|
||||
if (tooltipContent && !dropdown.getAttribute('aria-label')) {
|
||||
dropdown.setAttribute('aria-label', tooltipContent);
|
||||
}
|
||||
// a selection dropdown's text is its value, other dropdowns are button-like and named by their visible text
|
||||
if (!dropdown.classList.contains('selection') && !focusable.getAttribute('aria-label') && !focusable.getAttribute('aria-labelledby')) {
|
||||
const textElem = dropdown.querySelector<HTMLElement>(':scope > .text, :scope > span');
|
||||
if (textElem) {
|
||||
if (!textElem.id) textElem.id = generateElemId('_aria_dropdown_text_');
|
||||
focusable.setAttribute('aria-labelledby', textElem.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function attachInitElements(dropdown: AriaDropdownElement) {
|
||||
|
||||
Reference in new issue
Block a user