Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QDate has buttons with inaccessible names #16713

Open
hennzen opened this issue Dec 18, 2023 · 2 comments
Open

QDate has buttons with inaccessible names #16713

hennzen opened this issue Dec 18, 2023 · 2 comments
Labels
area/a11y Accessibility area/components bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@hennzen
Copy link

hennzen commented Dec 18, 2023

What happened?

Our app needs to comply with WCAG guidelines, which is why we plan to integrate automated checks into our build pipeline as a first stop, prior to manual checks. We strive to reduce the amount of (sometimes non-critical or even purely technical as per specs) errors reported by Lighthouse et al., so that the important errors stay visible.

Currently, QDate's buttons to flip between months or years (chevron-left/-right) as well as the "today" button cause an error "Buttons do not have an accessible name" (Lighthouse) resp. "Buttons must have discernible text" (AxeDevTools).

I think it's important to note that this a11y issue might not be mission critical, if we only use the QDate in conjunction with QInput. Impaired users can always use the QInput then.
That's our case, mostly, but we also display the QDate as a widget here and there, i.e. without QInput. So then it becomes important again.

What did you expect to happen?

The button elements should be using ARIA labels such as aria-label="[previous|next] [month|year]" or aria-label="today".

Reproduction URL

https://codepen.io/hennzen/pen/YzBmOVg

How to reproduce?

  1. Go to the provided CodePen
  2. Open DevTools to either use Lighthouse or AxeDevTools Tab
  3. Generate report

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Components (quasar), Accessibility [a11y] (quasar)

Platforms/Browsers

Firefox, Chrome

Quasar info output

No response

Relevant log output

No response

Additional context

No response

@hennzen hennzen added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Dec 18, 2023
@github-actions github-actions bot added area/a11y Accessibility area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite labels Dec 18, 2023
@yusufkandemir yusufkandemir added bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. and removed bug/1-repro-available A reproduction is available and needs to be confirmed. labels Dec 18, 2023
@pdanpdan
Copy link
Collaborator

I know the problem (this one and the QTable navigation buttons one).
The problem is that it needs lots of translations (all things should have i18n)

@hennzen
Copy link
Author

hennzen commented Jun 5, 2024

To solve this, I ended up creating a patch patches/quasar+2.16.4.patch with patch-package, and while I was at it, also added a tooltip with custom class to the today button:

--- a/node_modules/quasar/src/components/date/QDate.js
+++ b/node_modules/quasar/src/components/date/QDate.js
@@ -1,6 +1,7 @@
 import { h, ref, computed, watch, Transition, nextTick, getCurrentInstance } from 'vue'
 
 import QBtn from '../btn/QBtn.js'
+import QTooltip from '../tooltip/QTooltip.js'
 
 import useDark, { useDarkProps } from '../../composables/private.use-dark/use-dark.js'
 import useRenderCache from '../../composables/use-render-cache/use-render-cache.js'
@@ -1131,13 +1132,21 @@ export default createComponent({
 
           props.todayBtn === true ? h(QBtn, {
             class: 'q-date__header-today self-start',
+            ariaLabel: 'today',
             icon: $q.iconSet.datetime.today,
             flat: true,
             size: 'sm',
             round: true,
             tabindex: tabindex.value,
             onClick: setToday
-          }) : null
+          }, () => h(QTooltip, {
+              class: 'ui-tooltip',
+              transitionShow: 'scale',
+              transitionHide: 'scale',
+              delay: 500,
+              hideDelay: 200,
+              anchor: 'top middle',
+              self: 'center middle' }, () => 'today')) : null
         ])
       ])
     }
@@ -1155,6 +1164,7 @@ export default createComponent({
             icon: dateArrow.value[ 0 ],
             tabindex: tabindex.value,
             disable: boundaries.prev === false,
+            ariaLabel: `${ type === 'Months' ? 'previous month' : 'previous year' }`,
             ...getCache('go-#' + type, { onClick () { goTo(-1) } })
           })
         ]),
@@ -1187,6 +1197,7 @@ export default createComponent({
             icon: dateArrow.value[ 1 ],
             tabindex: tabindex.value,
             disable: boundaries.next === false,
+            ariaLabel: `${ type === 'Months' ? 'next month' : 'next year' }`,
             ...getCache('go+#' + type, { onClick () { goTo(1) } })
           })
         ])

The patch applies to node_modules/quasar/src/components/date/QDate.js, and in order to make this work, the parent component needs an explicit import

import { QDate } from '../../../node_modules/quasar/src/components/date'

This took me some time to figure out, because a import { QDate } from 'quasar' is directed to the module's dist directory, which of course stays unaffected.

Can anyone think of a better approach, say JSProxy or something?

I would always try to avoid the extra maintenance of having patches in a project, but then again, this patch is clearly arranged enough (only added lines) to cause no headache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/a11y Accessibility area/components bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

3 participants