diff --git a/general/development/policies/accessibility/coding-guidelines.md b/general/development/policies/accessibility/coding-guidelines.md new file mode 100644 index 000000000..f5bc64e0f --- /dev/null +++ b/general/development/policies/accessibility/coding-guidelines.md @@ -0,0 +1,741 @@ +--- +title: Coding guidelines +tags: + - Accessibility + - Coding guidelines +keywords: + - accessibility + - accessibility coding guidelines +--- + +All features in Moodle _must_ be accessible to all users regardless of their abilities. Therefore, accessibility must be built in from the planning and design stage through to development and testing, to ensure we release features that are accessible by default. + +## Semantic HTML + +It is highly recommended to use [semantic HTML](https://developer.mozilla.org/en-US/curriculum/core/semantic-html/). Doing so is important because using HTML elements for their intended purpose (for example, using ` +``` + +- An icon button labelled by its `aria-label` attribute. + +```html + +``` + +- An icon button with a visually hidden text label. + +```html + +``` + + + +:::warning Using non-semantic HTML: A link element as a button + +Consider the following example where a link element is used as a button: + +```html + + {{#str}} deletecategory, customfield, {{name}} {{/str}} + +``` + +For assistive technologies to properly recognise the link element as a button, we need to set a value of `button` for the `role` attribute. Additionally, as specified in the [ARIA Authoring Practices Guide (APG)](https://www.w3.org/WAI/ARIA/apg/patterns/button/), buttons are activated when pressing `Space` or `Enter` keys. Given that links are natively activated by pressing the `Enter` key only, links that act as buttons need to implement an event handler in JavaScript for the `Space` key press event. + +::: + +## Accessible Rich Internet Applications (ARIA) + +ARIA is a set of special attributes added to HTML to improve accessibility. It bridges the gap between HTML's native accessibility and the complex interactions of modern web applications. + +ARIA helps assistive technologies, like screen readers, understand dynamic and interactive web content. + +It defines: + +- Role (`toolbar`, `tooltip`, `button`, `menu`, `dialog`, etc.) +- States (`aria-expanded`, `aria-hidden`, etc.) +- Properties (`aria-haspopup`, `aria-label`, `aria-describedby`, etc.) + +to communicate what elements are and how they behave, and it is especially useful for making custom widgets and dynamic content accessible. + +### When to use ARIA? + +We typically use ARIA when creating interactive widgets for which there is no native HTML equivalent. Some examples include autocomplete form elements, searchable combo boxes, dropdown menus, and tabbed interfaces. + +We also use ARIA attributes to clarify relationships between elements on the page or their states. For example, we need to display a validation error message on a form field. We then use the `aria-describedby` attribute to indicate that the error message pertains to the form field with the invalid input. + +Another use of ARIA attributes is to enhance dynamic content updates, such as defining `aria-live` regions on parts of the page that are updated dynamically. This is especially important for assistive technology users, so they are promptly notified of changes when performing actions on the page. + +### What ARIA is not + +ARIA is not a replacement for semantic HTML. Sure, we can create a button element using a `` tag and assign it an ARIA role of `button`, but we already have the semantic ` +``` + + + + + +This example markup for a link that opens in a new window uses a decorative icon as an indication for sighted users that clicking on it will open the link in a new window. For screen reader users, the visually hidden text lets them know that it opens in a new window. + +```html + + {{linkname}} + {{#pix}} i/externallink, core {{/pix}} + + {{#str}} opensinnewwindowbracketed, core {{/str}} + + +``` + + + +#### Informative icons + +In some cases, an icon may be used to provide additional information that is not already conveyed by the text. For example, an icon next to a form field label to indicate that the field is required. In this case, the icon should have an appropriate accessible name to convey its meaning. + + + +This example passes a `required` language string to the Mustache `pix` helper for the icon's accessible name. + +```html + + {{#pix}}req, core, {{#str}} required, core {{/str}}{{/pix}} + +``` + +This renders an icon with an accessible name "Required" (or the equivalent in the user's language), and is visible to assistive technologies, such as screen readers. + +```html + +``` + + + +#### Target size + +It is important to ensure that an icon button's/link's target size (the clickable/touch area) is large enough and has sufficient spacing around it so that it can be easily activated by mouse, touch, and other pointer inputs. + +- The minimum target size for interactive elements is **24 by 24 CSS pixels**, as specified by [WCAG 2.2 Success Criterion 2.5.8: Target Size (Minimum) (Level AA)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html). +- For an enhanced experience, a target size of **44 by 44 CSS pixels** is recommended, as outlined in [WCAG 2.2 Success Criterion 2.5.5: Target Size (Enhanced) (Level AAA)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html). + +#### Useful resources + +- [Understanding Success Criterion 1.1.1: Non-text Content (Level A)](https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html) +- [Understanding Success Criterion 2.5.8: Target Size (Minimum) (Level AA)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html) + +### Keyboard support + +All interactive components must be fully operable through a keyboard-only interface. This ensures that users who cannot use a mouse, including those who rely on assistive technologies, can access and interact with all features. + +Some important things to keep in mind: + +- All interactive components must be focusable via the keyboard (that is, they are reachable using the `Tab` key). +- It must be possible to move focus away from any component using only the keyboard. A component must never "trap" focus. + - For example, if a modal dialogue is open, the user should be able to close it (for example, by pressing `Escape` or activating a `Close` button) and return focus to the element that triggered the dialogue using only the keyboard. +- The element that currently has focus must have a visible focus indicator. + +#### The `tabindex` attribute + +The `tabindex` attribute controls whether and how an element participates in the tab sequence. Only the following values should be used: + +- `tabindex="0"`: Adds the element to the natural tab order. Use this when a non-interactive element (such as a `
` or ``) needs to be focusable. Interactive elements like ` + +
+
+ +
+ +``` + +In addition to the HTML structure, the following keyboard interactions must be implemented in JavaScript: + +- `Left Arrow` / `Right Arrow`: Move focus between tabs. +- `Home` / `End`: Move focus to the first or last tab. +- `Space` or `Enter`: Activate the focused tab. + + + +#### Useful resources + +- [ARIA Authoring Practices Guide (APG) Patterns](https://www.w3.org/WAI/ARIA/apg/patterns/) +- [ARIA APG: Developing a Keyboard Interface](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/) + +### CSS and visual presentation + +CSS choices can have a direct impact on accessibility. The following areas require particular attention. + +#### Zoom and reflow + +Pages must remain usable when zoomed to 200% and 400%. Content should reflow into a single column at 400% zoom without horizontal scrolling or overlapping elements. Using Bootstrap's responsive grid system and relative units (such as `rem` and `em`) helps meet this requirement. + +#### CSS order versus DOM order + +If CSS is used to visually reorder elements differently from the DOM order (for example, using `order` in Flexbox or Grid), keyboard navigation will still follow the DOM order. This discrepancy can confuse keyboard users. Ensure that the visual order matches the DOM order, or provide custom keyboard navigation to account for the difference. + +#### Animations + +CSS animations and transitions can cause discomfort for users with vestibular disorders. From Moodle 4.3 onwards, CSS animations can be marked as non-essential by using the `optional-animation` SCSS mixin, which respects the user's `prefers-reduced-motion` system setting. + +#### Useful resources + +- [Understanding Success Criterion 1.4.4: Resize Text (Level AA)](https://www.w3.org/WAI/WCAG22/Understanding/resize-text.html) +- [Understanding Success Criterion 1.4.10: Reflow (Level AA)](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html) +- [Understanding Success Criterion 2.3.3: Animation from Interactions (Level AAA)](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html) + +## External resources + + + + + +- [W3C Accessibility Standards Overview](https://www.w3.org/WAI/standards-guidelines/) +- [Accessible Rich Internet Applications (WAI-ARIA) 1.2](https://www.w3.org/TR/wai-aria-1.2/) +- [ARIA Authoring Practices Guide (APG)](https://www.w3.org/WAI/ARIA/apg/) +- [Web Content Accessibility Guidelines (WCAG) 2.2](https://www.w3.org/TR/WCAG22/) +- [Authoring Tool Accessibility Guidelines (ATAG) 2.0](https://www.w3.org/TR/ATAG20/) +- [User Agent Accessibility Guidelines (UAAG) 2.0](https://www.w3.org/TR/UAAG20/) +- [WebAIM: Web Accessibility In Mind](https://webaim.org/) +- [Deque University Web Accessibility Checklist](https://dequeuniversity.com/checklists/web/) diff --git a/general/development/policies/accessibility/index.md b/general/development/policies/accessibility/index.md index dd58ee281..9d55beab5 100644 --- a/general/development/policies/accessibility/index.md +++ b/general/development/policies/accessibility/index.md @@ -129,163 +129,6 @@ One example of this is in the "Atto text editor" which includes an "Accessibilit All accessibility features of the "MathJax" content filter are enabled as standard, allowing screen readers to read math content directly. -## Coding standards - -All components in Moodle _must_ be available for use by all users. Accessibility needs to be part of the design of every new feature in Moodle. - -For simple features with no requirement for an advanced user interface, simple adherence to standard HTML5 does provide an accessible feature. In this case, [advice from W3C](https://www.w3.org/TR/wai-aria-practices/#no_aria_better_bad_aria) is not to use ARIA at all than to use it incorrectly. - -Bootstrap and Bootstrap components [do not support accessibility by default](https://getbootstrap.com/docs/4.0/getting-started/accessibility/#color-contrast). All features implemented using Bootstrap components _must be_ checked and enhanced where necessary. Moodle has created an "aria" JavaScript module which improves accessibility features of some default Bootstrap features, including menus. - -### Colours - -All text that is presented needs to be displayed in a colour with sufficient contrast to its background colour so that the text is legible for all users. The foreground and background colours should meet the [WCAG requirement for contrast](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html), which varies depending on the size of the text. This can be tested with the [WebAIM Web Accessibility Evaluation Tool](https://wave.webaim.org/). - -It is worth noting that colour alone **must not** be used to imply meaning. An example of a failure for this would be to display error messages in "red" with no other information to convey that this is an error message. - -See [the W3C advice on the use of colour](https://www.w3.org/TR/WCAG22/#use-of-color) from WCAG 2.2 for more information. - -### Icons - -Icons (Images) can be displayed in a variety of ways, and the correct use of icons will depend on the context in which they are used. - -See [the WCAG 2.2 requirement for text alternatives](https://www.w3.org/TR/WCAG22/#text-alternatives) for more information. - -#### Solitary Icons - -Icons displayed on their own, as part of a link or as informative content must include accessible text to convey the meaning of the icon. For an image tag, this can be the `"alt"` attribute for the image tag. It can be valid to include both the `"alt"` attribute and the "title" attribute (shown when hovering with the mouse) so that all users can access the textual meaning of the icon. - -#### Icons and Text - -When an icon is displayed immediately before or after some text that also describes the meaning of the icon, it is redundant to repeat the same text twice. In this case, it is correct to hide the icon from screen readers by setting the "role" attribute to "presentation" or hiding it with the "aria-hidden" attribute set to "true". - -#### Multiple icons - -When multiple icons are displayed in a row as links, it is important that each icon is large enough and has sufficient space around it so the icon can be easily clicked with the mouse. - -The minimum valid size for a link target is 44 by 44 pixels. - -See [the WCAG 2.2 requirement for target size](https://www.w3.org/TR/WCAG22/#target-size) for more information. - -### Keyboard Support - -All components should be entirely operable through a keyboard-only interface. - -See [the WCAG 2.2 requirement for keyboard accessibility](https://www.w3.org/TR/WCAG22/#keyboard-accessible) for more information. - -Some important things to consider is that all components should be focusable with the keyboard (available in the tab sequence), and should allow the focus to be moved away using only the keyboard. - -The element that currently has focus should have a visual focus indicator. The W3C provide information on [ARIA focus management](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_focus_discernable_predictable) as part of it's ARIA best practices. - -In some cases, a single component can contain many smaller components. In order to not pollute the page tab sequence, the parent element can exist in the tab sequence once and should maintain focus within its smaller components with arrow key navigation (roving `tabindex` or active descendant). The W3C provide information [ARIA keyboard navigation inside components](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_general_within) as part of it's ARIA best practices. - -### Forms - -Moodle forms created with the standard forms library are designed to be accessible. Any custom (for example JavaScript) form or custom form elements must also be accessible. - -- All form elements must have a label -- The form must be able to be completed entirely with the keyboard -- Invalid entries in the form fields should be indicated with the "aria-invalid" attribute set to "true" -- Warning messages for invalid form fields should be associated with the invalid field using the "aria-describedby" attribute. See [the WCAG 2.2 success criteria for Error Identification](https://www.w3.org/TR/WCAG22/#error-identification) for further information on this. - -### Presentation Only - -Any component that contains no information or functionality that is not provided by other components on the page can be considered decorative only. Content that meets this description can be hidden from screen readers using a suitable technique (aria-hidden or presentation role). - -See [the WCAG 2.2 description of pure decoration](https://www.w3.org/TR/WCAG22/#dfn-pure-decoration) for more information. - -### Landmark regions - -The layout of each page of content should be separated into valid regions where each region has a unique label and the correct landmark role. This is typically done in the layout files of the theme. - -See [the ARIA best practice advice on landmarks](https://www.w3.org/TR/wai-aria-practices-1.1/#aria_landmark) for further information. - -### Page Titles - -All pages should have a unique title that describes the current page. - -Some tips for providing a meaningful page title: - -- The page title must be accurate and informative. -- If the page causes a _change of context_ (for example, a search functionality), it should describe the result or change of context to the user. -- It should be concise. -- If possible, it should uniquely identify the page. -- The most identifying information should come first. - -:::note change of context - -(not to be confused with Moodle's `\core\context` class and its implementations) - -According to the [WCAG 2.2 Understanding Docs](https://www.w3.org/WAI/WCAG22/Understanding/on-focus.html#dfn-changes-of-context), a change in context is a major change that, if made without user awareness, can disorient users who are not able to view the entire page simultaneously. It can include changes of user agent, viewport, focus, or content that changes the meaning of the web page. - -::: - -#### Example - -Consider that a student is on the submission page of an assignment activity called `Kinetics problem set 1` in the `Physics 101` course on the `Mount Orange School` Moodle site. - -Then a suitable page title for the page would be something like: - - - -The most unique identifying information first represented by the activity name and its sub-page, then followed by broader identifiers such as the course name and the site name. - -`Kinetics problem set 1: Submit assignment | Physics 101 | Mount Orange School` - - - - - -The most unique identifying information first represented by the name of the sub-page, followed by the activity name that the page belongs to, then followed by broader identifiers such as the course name and the site name. - -`Submit assignment | Kinetics problem set 1 | Physics 101 | Mount Orange School` - - - -#### Separating components of a page title - -When separating the components of the page tile, please use the `moodle_page::TITLE_SEPARATOR` constant. - - - -```php -[$course, $cm] = get_course_and_cm_from_cmid($id); -// Activity name and its sub-page as the unique identifying information. -$pagename = format_string($cm->name) . ': ' . get_string('view'); -// Course name. -$coursename = format_string($course->fullname); -// Set the page title, combining the activity page's name and course name using the title separator constant. -$PAGE->set_title($pagename . moodle_page::TITLE_SEPARATOR . $coursename); -``` - - - -#### Site name on the page title - -You should not add the name of the site when setting the page title using `$PAGE->set_title()`. The site name is automatically appended to the end of the page title in the correct format when using `$PAGE->set_title()`. - -:::info - -Administrators can use the `sitenameinititle` configuration setting to configure how this is shown in the title with possible options including: - -- the _full name_ of the site, for example, "Mount Orange School" -- the _short name_ of the site, for example: "MOS" - -This is automatically handled by `$PAGE->set_title()`. -::: - -#### Useful resources - -- [Understanding Success Criterion 2.4.2: Page Titled (Level A)](https://www.w3.org/WAI/WCAG22/Understanding/page-titled) -- [Technique G88: Providing descriptive titles for Web pages](https://www.w3.org/WAI/WCAG22/Techniques/general/G88) - -### Advanced UX Widgets - -When it is determined that an advanced interface is required (typically one that relies on JavaScript), a minimum set of principles need to be applied to make sure that the feature "provides equal functionality and information to all people". Each use case is different, but a minimum set of things to be checked are: - -- Does this component work entirely when accessed only via the keyboard? -- Does this component map to any widget from the [ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.1/) document and if so, does it implement all of the "Keyboard Interaction" and "WAI-ARIA Roles, States and Properties" listed for that widget? - ## External Resources diff --git a/general/development/policies/codingstyle/index.md b/general/development/policies/codingstyle/index.md index 04c0ba880..c7ac15d55 100644 --- a/general/development/policies/codingstyle/index.md +++ b/general/development/policies/codingstyle/index.md @@ -2022,4 +2022,4 @@ This document was drawn from the following sources: - [Coding](../../policies.md) - [CodeSniffer](../../policies/codingstyle/index.md) - [Code Checker plugin](https://moodle.org/plugins/local_codechecker) -- [Accessibility coding guidelines](../accessibility/index.md#coding-standards) +- [Accessibility coding guidelines](../accessibility/coding-guidelines.md) diff --git a/general/development/process/peer-review/accessibility-checklist.md b/general/development/process/peer-review/accessibility-checklist.md index 012438271..61abd8497 100644 --- a/general/development/process/peer-review/accessibility-checklist.md +++ b/general/development/process/peer-review/accessibility-checklist.md @@ -7,188 +7,300 @@ tags: sidebar_position: 4 --- - + -This document proposes a checklist for accessibility reviews. Not all aspects of accessibility can be checked automatically, so this checklist is intended to guide reviewers when doing an accessibility check to a patch. +This checklist helps reviewers perform an accessibility review of a patch. It is designed to be used alongside the [Accessibility coding guidelines](../../policies/accessibility/coding-guidelines.md) and the [Accessibility testing](../../policies/accessibility/testing.md) documentation. -:::tip Identify the Nature of Changes +:::tip Before you start: identify the nature of the changes -1. **Are the changes on the backend only (webservices, database updates, events, hooks...)?** - - If yes, no accessibility review is needed. -2. **Are there changes to the HTML, CSS, or JavaScript?** - - If yes, an accessibility review is necessary. -3. **Do the changes only involve standard HTML elements without altering default browser behaviour?** - - If yes, a quick accessibility check is recommended, but a complete review may not be necessary. +- **Backend only** (web services, database, events, hooks)? → No accessibility review needed. +- **Changes to HTML, CSS, or JavaScript?** → Accessibility review is necessary. Use this checklist. +- **Only standard HTML elements, no custom behaviour?** → A quick check is recommended, but a full review may not be needed. ::: -## Do an automated check +## Quick-reference checklist -Use the automatic accessibility checks via [Axe DevTools](https://www.deque.com/axe/devtools/) or [WAVE Web Accessibility Evaluation Tool](https://wave.webaim.org/)) to check for common issues. If there are any issues, the changes must be fixed before continuing. +Use this as a quick scan. If any item fails or you are unsure, refer to the detailed section linked in each item. -When possible, run an HTML validator and check for errors. For example, using [Nu HTML validator](https://validator.w3.org/nu/#textarea). +### Automated -## General Checks +- [ ] Run [Axe DevTools](https://www.deque.com/axe/devtools/) or [WAVE](https://wave.webaim.org/) on the affected page(s). Fix any issues before continuing. -Those are some quick checks you can do to ensure that the changes are accessible. +### Structure and semantics -### Use of tabindex +- [ ] The page has a descriptive, unique **page title** with the most specific information first. ([Details](#page-title-and-headings)) +- [ ] There is exactly one **`h1`** heading and the heading hierarchy has no skipped levels. ([Details](#page-title-and-headings)) +- [ ] **Semantic HTML** elements are used (for example, ` -``` +## Detailed guidance -```html title="Another example using fontawesome icons" - -``` +The sections below provide more context for each checklist item. For full explanations and code examples, refer to the [Accessibility coding guidelines](../../policies/accessibility/coding-guidelines.md). -### Visible focus +### Run an automated check -All focusable elements should have a visible focus indicator that should be **different** from the default browser focus indicator. The focus indicator should be visible in all states (normal, hover, focus, active, disabled). +Run an automated accessibility checker on the affected page(s) before starting the manual review: -By default, Moodle overrides the focus indicator of most HTML elements to ensure accessibility. However, in some cases, it is necessary to add extra CSS rules to ensure the focus indicator is visible and has enough contrast. For those cases, Moodle provides some CSS helpers: +- [Axe DevTools](https://www.deque.com/axe/devtools/) or [WAVE Web Accessibility Evaluation Tool](https://wave.webaim.org/) +- An HTML validator such as the [Nu HTML validator](https://validator.w3.org/nu/#textarea) -- Adding `aalink` to a link (or any other element acting as a link) will ensure the focus indicator is visible. -- The CSS class `focus-visible` should be used to ensure the focus indicator is only visible when the element is focused using the keyboard. -- In action menus or action menu sub panels, you can use `dropdown-item-outline` to ensure the focus indicator is visible on all the item and not only in the link element within. +Any reported issues must be fixed before continuing with the manual review. -### Page headers and title +
+Related documentation -Each new page should have a specific and descriptive page title. +- [Accessibility testing > Automated testing](../../policies/accessibility/testing.md#automated-testing) — browser extensions, built-in dev tools, and Behat accessibility tests -:::info Example +
-Use "Settings in forum ACTIVITYNAME" instead of just "Activity settings". +### Page title and headings -::: +- The page must have a descriptive, unique **page title**. The most specific information should come first (for example, "Submit assignment | Kinetics problem set 1 | Physics 101" rather than "Physics 101 | Activity"). +- There must be exactly **one `h1`** heading on the page. It should reflect the page title. +- Headings must follow a **strict hierarchy** — no skipped levels (for example, `h2` followed directly by `h4`). + +
+Related documentation + +- [Coding guidelines > Page titles](../../policies/accessibility/coding-guidelines.md#page-titles) +- [Coding guidelines > Headings](../../policies/accessibility/coding-guidelines.md#headings) + +
+ +### Keyboard operability + +- **Tab** through every interactive element on the page. Ensure all buttons, links, form fields, and custom widgets are reachable. +- **Activate** elements using `Enter` and/or `Space` as appropriate. +- Confirm that focus is **never trapped** — you must always be able to leave a component (for example, pressing `Escape` to close a modal). +- Complete typical user tasks using only the keyboard. + +
+Related documentation + +- [Coding guidelines > Keyboard support](../../policies/accessibility/coding-guidelines.md#keyboard-support) +- [Accessibility testing > Keyboard navigability and operability tests](../../policies/accessibility/testing.md#keyboard-navigability-and-operability-tests) + +
+ +### `tabindex` values + +- `tabindex` greater than `0` (for example, `tabindex="1"`) is **always wrong**. Only `0` and `-1` are acceptable. +- If `tabindex="0"` is on a natively focusable element (` +``` -- Add a span with `sr-only` class to the element. The `sr-only` class is only visible for assistive technologies. -- If parts of the link meaning is represented by an icon, add an `alt` text to the icon so it will be read with the rest of the link text. +
+Related documentation -### Is CSS ordering elements different than DOM? +- [Coding guidelines > Semantic HTML](../../policies/accessibility/coding-guidelines.md#semantic-html) -If yes, it can cause unexpected behaviour for keyboard users. The patch should provide an ad-hoc keyboard navigation using an AMD module. +
-### When the new elements are focused, do the down and tab keys still work in the default way? +### Link text -If not means the code has a pointer cancellation. In this case the patch should implement a proper custom component pattern. See [Review Custom Components](#review-custom-components) for more information. +- Link text must clearly describe the link's purpose. Avoid "click here", "read more", "here", or "more info". +- If multiple links share the same visible text but go to different destinations, add visually hidden text to make each link unique. -### Does Any of the elements have a CSS animation? +
+Related documentation -If yes, it is recommended the patch should provide a way to stop the animation. +- [Coding guidelines > Links](../../policies/accessibility/coding-guidelines.md#links) -From Moodle 4.3 onwards, any CSS animation could be marked as optional by importing the `optional-animation` SCSS mixin. +
-### Does the patch adds tabindex="0" to any element? +### Custom components -If yes, there are a few things you need to check: +When the patch introduces custom interactive widgets (for example, tabs, modals, dropdown menus), check that: -- If the element is a link, a button or a form control, then the `tabindex` should be removed. -- Otherwise, the element should also provide a proper `role` attribute to indicate the assistive technology how to interact with it. For example, if the element acts a a button it should have a `role="button"` attribute. +- The widget follows a recognised [ARIA APG pattern](https://www.w3.org/WAI/ARIA/apg/patterns/). +- All keyboard interactions from the APG pattern are implemented. +- The correct ARIA roles, states, and properties are used and updated via JavaScript. -### Does the page use visuals like empty space, indentations or colors to represent structure or precedence? +
+Related documentation -If yes, then this structure should also be represented in the HTML (nested lists, or by adding [`role="list"`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/List_role)) or using explanatory -textual elements. +- [Coding guidelines > Advanced UX widgets](../../policies/accessibility/coding-guidelines.md#advanced-ux-widgets) +- [Accessibility testing > Keyboard navigability and operability tests](../../policies/accessibility/testing.md#keyboard-navigability-and-operability-tests) +- [Accessibility testing > Screen reader testing](../../policies/accessibility/testing.md#screen-reader-testing) -### Does the page have elements that only appear on hover or focus? +
-If yes, then the patch should provide a way to make those elements visible for keyboard users. +### Dynamic content -Disappearing elements should be avoided when possible. However, in some pages decluttering the UI is necessary. In those cases, Moodle provides some CSS helpers to ensure the element will still be visible for keyboard users: +If parts of the page are updated dynamically via JavaScript, check that: -1. Add a `focus-control` class to the parent container. It is important the parent container has some visible focus element (for example, a link or a button), otherwise it cannot be browsable using the keyboard. -2. Add `v-parent-focus` to all elements that should appear only when the parent container has a focus within. +- The container uses **`aria-live`** (`"polite"` for non-urgent updates, `"assertive"` for urgent ones) so screen readers announce changes. +- While loading, the container has **`aria-busy="true"`** (removed once complete). +- **Focus is managed** — if content is inserted, focus moves to it; if content is removed, focus returns to the triggering element. -## Review Custom Components +
+Related documentation -Custom JavaScript keyboard controls should be implemented when creating custom interactive elements using non-interactive HTML elements, or when dealing with complex widgets like tabs, modals, or custom select menus. However, these custom controls should mimic the standard browser navigation as closely as possible. +- [Coding guidelines > Dynamic content](../../policies/accessibility/coding-guidelines.md#dynamic-content) +- [Accessibility testing > Screen reader testing](../../policies/accessibility/testing.md#screen-reader-testing) -Conduct an in-depth review focusing on proper usage of ARIA roles and attributes, keyboard accessibility, and interaction feedback. Any custom component should fit one of the [patterns](https://www.w3.org/WAI/ARIA/apg/patterns/) defined by the ARIA Authoring Practices Guide. +
-### Review Dynamic Content +### Forms -If the patch partially update the page content using JavaScript, check: +Unless the patch uses custom form fields, Moodle forms (moodleforms) are already accessible. For **custom forms**, check: -- If the changes are announced to screen readers. This can be done by using the [`aria-live`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live) attribute. -- While the element is updating, the element should have a [`aria-busy="true"`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-busy) attribute to prevent the user from interacting with the element until the update is finished. Once the update is finished, the attribute should be removed. -- The focus is managed correctly. For example, if the focus is moved to a new element, the focus should be moved back to the original element when the new content is removed. +- Every field has a **`