fix: [OCISDEV-115] address post-merge review on coloured tags (#12923)

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 `<tr>` 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.
This commit is contained in:
Gaurav Soni authored and GitHub committed 2026-09-10 15:44:25 +02:00
1 parent ddc34232f8
commit 29392cea9c
5 files changed
+81 -13

No files matched your search

@@ -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
@@ -39,6 +39,7 @@
name="lock"
size="small"
variation="inherit"
:accessible-label="$gettext('Read-only tag')"
/>
<oc-button
v-else
@@ -139,20 +139,19 @@
size="small"
class="resource-table-tag-more"
:aria-label="getTagsOverflowAriaLabel(item)"
aria-haspopup="true"
:aria-expanded="isTagsOverflowExpanded(item)"
@click="keepClickWithinTagsOverflow"
>
+ {{ item.tags.length - 2 }}
</oc-tag>
<!--
`is-nested` is set for its side effect, not its literal meaning: it suppresses the
`hideAll` that OcDrop otherwise runs on show. Without it, merely moving the pointer
across a row's tag overflow would dismiss an open context menu.
-->
<oc-drop
v-if="item.tags.length > 2"
:toggle="`#tags-overflow-${resourceDomSelector(item)}`"
mode="hover"
:is-nested="true"
mode="click"
class="resource-table-tag-overflow"
@show-drop="setTagsOverflowExpanded(item, true)"
@hide-drop="setTagsOverflowExpanded(item, false)"
>
<component
:is="userContextReady ? 'router-link' : 'span'"
@@ -486,9 +485,27 @@ const getTagToolTip = (text: string) => (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<Record<string, boolean>>({})
const isTagsOverflowExpanded = (item: Resource) =>
unref(tagsOverflowExpanded)[resourceDomSelector(item)] === true
const setTagsOverflowExpanded = (item: Resource, expanded: boolean) => {
tagsOverflowExpanded.value[resourceDomSelector(item)] = expanded
}
const isResourceDisabled = (resource: Resource) => {
@@ -758,6 +758,44 @@ describe('ResourceTable', () => {
expect(moreButton.attributes('aria-label')).toBeTruthy()
})
it('keeps the visible "+ N" inside the accessible name', () => {
const resource = mock<Resource>({ 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<Resource>({ 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<Resource>({ 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
@@ -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)