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)