From 29392cea9ccfbab2ba5cfb14ff39084a18aeb972 Mon Sep 17 00:00:00 2001 From: Gaurav Soni Date: Thu, 10 Sep 2026 15:44:25 +0200 Subject: [PATCH] fix: [OCISDEV-115] address post-merge review on coloured tags (#12923) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five review comments landed on #12892 after it merged. **The tag overflow popover dismissed itself on click.** `mode="hover"` maps to tippy's `mouseenter focus` trigger, and `hideOnClick` is hardcoded true in `OcDrop`. tippy only skips its document-press hide when the trigger contains `click`, so a click on the button fell through to `hide()` and set `didHideDueToDocumentMouseDown`, which then blocked the focus trigger from reopening it — the pointer had to leave and come back. `mode="click"` fixes it without touching the design system: tippy toggles a click-triggered instance, so the button opens and closes it, Enter/Space work because a native button activation dispatches a click, and Escape still closes via the `hideOnEsc` plugin with a click able to reopen it. Under `hover` that last one was a dead end — Escape hid the popover and no new focus event could follow. The trade is that hovering no longer reveals the tags; a disclosure that answers to the keyboard is worth more than a hover shortcut. That click also had to stop propagating: the button sits inside the `` that `OcTable` highlights on click, so opening the popover selected the file as well. tippy's listener is on the same element, so stopping propagation still toggles the popover. `is-nested` goes with it. It was set purely to suppress the `hideAll` that ran when a pointer crossed the button, and pointer movement no longer opens anything. Dropping it also un-silences `showDrop`/`hideDrop`, which `OcDrop` only emits for drops that are not nested. **The button claimed to be a popover trigger without saying so.** It now carries `aria-haspopup` and an `aria-expanded` driven by those two events. tippy manages `aria-expanded` itself only when the reference does not already have one (`hasAriaExpanded` is read once at create time), and Vue renders the attribute before `OcDrop` mounts, so there is one owner, not two. **The accessible name dropped the visible text.** WCAG 2.5.3 Label in Name wants the visible `+ 3` inside the name; `Show 3 more tags` left speech input with nothing to match. The count now leads the string. **The read-only tag lock was invisible to screen readers.** No `accessible-label` means `OcIcon` renders it `aria-hidden`, so the only signal that a tag cannot be removed was the absent deselect button. **Themes inherited no tag palette.** `tagColorsList` was missing from `defaults.designTokens`, so a deployment serving its own theme.json gets grey chips. Seeding the defaults with the light palette turned out to be the wrong place for it: every other value in that block is an empty-string placeholder, because supplying colours is a theme's responsibility. The defaults stay colourless. `useTagColor` already returns -1 without a list and `OcTag` then renders the plain chip, which is what tags looked like before this feature. --- .../unreleased/enhancement-coloured-tags.md | 8 ++-- .../components/SideBar/Details/TagsSelect.vue | 1 + .../components/FilesList/ResourceTable.vue | 37 +++++++++++++----- .../FilesList/ResourceTable.spec.ts | 38 +++++++++++++++++++ .../tests/unit/helpers/theme.spec.ts | 10 +++++ 5 files changed, 81 insertions(+), 13 deletions(-) diff --git a/changelog/unreleased/enhancement-coloured-tags.md b/changelog/unreleased/enhancement-coloured-tags.md index a2a12e7fc5e..bd0f44f2231 100644 --- a/changelog/unreleased/enhancement-coloured-tags.md +++ b/changelog/unreleased/enhancement-coloured-tags.md @@ -9,8 +9,10 @@ colour being stored anywhere. Themes supply the palette through a new `designTokens.tagColorsList`, and the label colour is chosen per fill so it stays legible in both the light and dark themes. -The tag overflow indicator on the files list also became a real, keyboard -reachable button, and it now shows the hidden tags in a popover instead of -opening the sidebar. +The tag overflow indicator on the files list also became a disclosure button +that shows the hidden tags in a popover instead of opening the sidebar. It +opens on click or on Enter/Space, closes on Escape, and reports its state to +assistive technology. https://github.com/owncloud/ocis/pull/12892 +https://github.com/owncloud/ocis/pull/12923 diff --git a/web/packages/web-app-files/src/components/SideBar/Details/TagsSelect.vue b/web/packages/web-app-files/src/components/SideBar/Details/TagsSelect.vue index 7f13c48823e..5507f2cacfe 100644 --- a/web/packages/web-app-files/src/components/SideBar/Details/TagsSelect.vue +++ b/web/packages/web-app-files/src/components/SideBar/Details/TagsSelect.vue @@ -39,6 +39,7 @@ name="lock" size="small" variation="inherit" + :accessible-label="$gettext('Read-only tag')" /> + {{ item.tags.length - 2 }} - (text.length > 7 ? text : '') const getTagsOverflowAriaLabel = (item: Resource) => { const count = item.tags.length - 2 - return $ngettext('Show %{count} more tag', 'Show %{count} more tags', count, { - count: count.toString() - }) + return $ngettext( + '+ %{count}, show %{count} more tag', + '+ %{count}, show %{count} more tags', + count, + { + count: count.toString() + } + ) +} + +const keepClickWithinTagsOverflow = (event: MouseEvent) => { + event.stopPropagation() +} + +const tagsOverflowExpanded = ref>({}) + +const isTagsOverflowExpanded = (item: Resource) => + unref(tagsOverflowExpanded)[resourceDomSelector(item)] === true + +const setTagsOverflowExpanded = (item: Resource, expanded: boolean) => { + tagsOverflowExpanded.value[resourceDomSelector(item)] = expanded } const isResourceDisabled = (resource: Resource) => { diff --git a/web/packages/web-pkg/tests/unit/components/FilesList/ResourceTable.spec.ts b/web/packages/web-pkg/tests/unit/components/FilesList/ResourceTable.spec.ts index 9dbdefc2a3a..11dda25549f 100644 --- a/web/packages/web-pkg/tests/unit/components/FilesList/ResourceTable.spec.ts +++ b/web/packages/web-pkg/tests/unit/components/FilesList/ResourceTable.spec.ts @@ -758,6 +758,44 @@ describe('ResourceTable', () => { expect(moreButton.attributes('aria-label')).toBeTruthy() }) + it('keeps the visible "+ N" inside the accessible name', () => { + const resource = mock({ id: '1', tags: ['1', '2', '3', '4'] }) + const { wrapper } = getMountedWrapper({ props: { resources: [resource] } }) + const moreButton = wrapper.find(`[data-item-id="${resource.id}"] .resource-table-tag-more`) + + expect(moreButton.text()).toBe('+ 2') + expect(moreButton.attributes('aria-label')).toContain('+ 2') + }) + + it('announces the overflow button as a disclosure and follows the popover state', async () => { + const resource = mock({ id: '1', tags: ['1', '2', '3'] }) + const { wrapper } = getMountedWrapper({ props: { resources: [resource] } }) + const row = wrapper.find(`[data-item-id="${resource.id}"]`) + const drop = row.findComponent({ name: 'OcDrop' }) + + expect(drop.props('mode')).toBe('click') + + expect(row.find('.resource-table-tag-more').attributes('aria-haspopup')).toBe('true') + expect(row.find('.resource-table-tag-more').attributes('aria-expanded')).toBe('false') + + await drop.vm.$emit('showDrop') + expect(row.find('.resource-table-tag-more').attributes('aria-expanded')).toBe('true') + + await drop.vm.$emit('hideDrop') + expect(row.find('.resource-table-tag-more').attributes('aria-expanded')).toBe('false') + }) + + it('does not select the row when the overflow button is clicked', async () => { + const resource = mock({ id: '1', tags: ['1', '2', '3'] }) + const { wrapper } = getMountedWrapper({ props: { resources: [resource] } }) + + await wrapper + .find(`[data-item-id="${resource.id}"] .resource-table-tag-more`) + .trigger('click') + + expect(wrapper.emitted('update:selectedIds')).toBeUndefined() + }) + it('marks the overflow popover so it can be sized to the tags it holds', () => { // `OcDrop` is a fixed 300px wide, which leaves most of the popover empty when the // overflow holds a single short tag. The class is what the stylesheet hangs the diff --git a/web/packages/web-runtime/tests/unit/helpers/theme.spec.ts b/web/packages/web-runtime/tests/unit/helpers/theme.spec.ts index 89a0449bc35..a7b7bedea52 100644 --- a/web/packages/web-runtime/tests/unit/helpers/theme.spec.ts +++ b/web/packages/web-runtime/tests/unit/helpers/theme.spec.ts @@ -36,6 +36,16 @@ describe('theme loading and error reporting', () => { expect(success).toBeTruthy() }) + it('every theme carries a tag colour list of the same length', () => { + const lengths = defaultTheme.clients.web.themes.map( + (theme) => theme.designTokens.tagColorsList.length + ) + + expect(lengths.length).toBeGreaterThan(0) + expect(new Set(lengths).size).toBe(1) + expect(lengths[0]).toBeGreaterThan(0) + }) + it('should load the default theme if location is empty', async () => { const theme = await loadTheme() expect(theme).toMatchObject(defaultOwnCloudTheme)