-
Derk-Jan Karrenbeld authored
* Add label and accessible content Having a select element without a label outside a form isn't directly problematic, but the text Version is the label of the select and should act as such. Because the select element is set up to browse to a different page which loses the current focus position, users must be instructed about this context change. It would be much better to display this content to everyone, but having this for screenreaders only is better than not having it at all. * Fix accessible text for voice commands Using the title attribute means some screenreaders will not be able to show the expanded accessible text at all, but using aria-label loses the hover text currently available. If the title attribute is still used, the accessible label should start with the same content as the visible label. This is necessary for most voice operated tooling which only match starting text. Having "Return" as the start of the accessible label and "Guides" as the start of the visible label means in most cases users that rely on voice commands will not be able to browse here. * Add utilities for screen readers This enables hiding content visually whilst still enabling it for assisistive technologies. * Feature detection for JavaScript functionalities * Add landmarks to all guide pages Landmarks such as header, section, footer, article, and the main content landmark help navigating when using assistive tooling. Since each guide is a self-contained article, a header section with the guide introduction and navigation, a footer section which is not part of the content but a call to action, and the rest can be clearly separated, landmarks here are appropiate. * Make back-to-top work without JavaScript By doing feature detection on animation timeline CSS, the graceful degradation can take care of the visiblity of the back-to-top button. In case no JavaScript is available, it should always be shown. * Enable back-to-top without JavaScript And add an accessible label to the button. It would be better to just show the text back to top underneath the arrow, but this change is again better than not having it at all. * Consistent scrolling behaviour respecting pref Use the preference to detect if a user wants reduced motion and if not enable smooth scrolling. This takes care of the back-to-top smooth scrolling, and also adds it to anchor links. If this is unwanted, the change can be reverted and a matchmedia check should be done in JavaScript instead before smooth scrolling * Add skip links to quickly navigate past navs Skip links are a common practice to allow keyboard and other users to skip past large blocks of content that are present on every page, which in this case are the secondary navigation at the top, the version selector, and the chapter navigation. The skip links only show when focused. * Wrap tables to make them responsive * Make back-to-top link to skip link This allow screen readers to announce something, because linking to an empty fragment or the body element doesn't announce anything usefull. * Fix false positive for broken (skip) link anchor * Add branded selectable color Fixes selecting text in dark mode and brands it for both modes. * Make more info and guides index accessible * Adds aria-controls, which binds the control to the content. * Adds aria-expanded, which signals the current expansion state. * Adds focus handling, which focuses the first link or the button depending on the expansion state. * Adds keyboard closing for the more info button. * Adds outside click tracking to close the expanded content. * Fixes the more info button to not be focusable. * Fix CSS for more info button * Fix dark mode for guide selector * Add accessible label for guide navigator * Only use nav on sub-column if it's actually a nav On the index page the sub-column is not a navigational element and does not contain content that needs to be skipped over. Therefore it should not be a <nav> and not contain a skiplink. Furthermore, the definition list doesn't contain any definitions, thus its role should be removed. * Ignore turbo for in-page skiplinks This ensures the JavaScript doesn't overridde any screenreader behaviour and the resulting fragment is correctly focused as expected. * Use keydown for escape detection When an action should be perceived as fast, or no pause is required before the interaction, keydown should be used and not keyup, which can add (the feeling of a) significant delay. * Fix heading levels It is important that the heading structure (all hx elements) are properly closed, and make sense. They can only ever increment by 1 since the previous heading (and decrement by many). * Presentational picture needs aria-hidden="true" The picture here adds a visual gimmic, but doesn't provide information to the user and thus should be removed from the accessibility tree. * JS-enabled link-as-button should have correct role When JavaScript is enabled, this link turns into a button that expands an element. The change ensures that screenreaders only announce it as such if JavaScript is enabled and applied. * Accessible regions, focusable anchors, cleanup Applied requested changes from review. See PR for discussion about explicitly adding a role="region" https://github.com/rails/rails/pull/51499 * Apply requested changes from review and re-apply after rebase * Adapt the highlight in the navigation side column for the new page structure. Additionally, replace the active class with aria-current="true", which is meant to keep track of what is currently active in a set. Finally, update the implementation of the intersection observer to: * not rely on the viewport height (-95%) * not rely on fixing the highlighted item after click * support both scrolling up and scrolling down * support fast scrolling * Apply review commentary * Fix issues with scrolling behaviour To "restore" the current behaviour on main, a solution was needed for browser-OS combinations that do not allow for two concurrent scrolling elements. Current code on main breaks completely when using scroll-behaviour: smooth (in CSS), and breaks when scrolling back-to-top from the bottom of the page (highlight no longer correct). This commit works around the limitation whilst also enabling the non-smooth scrolled solution for those who want reduced motion. Additionally it has a workaround for a bug on Android, and some defaults for those without JavaScript enabled. * Ensure chapters list is always scrolled after scroll-end Co-authored-by:
Rafael Mendonça França <rafael@rubyonrails.org>
Derk-Jan Karrenbeld authored* Add label and accessible content Having a select element without a label outside a form isn't directly problematic, but the text Version is the label of the select and should act as such. Because the select element is set up to browse to a different page which loses the current focus position, users must be instructed about this context change. It would be much better to display this content to everyone, but having this for screenreaders only is better than not having it at all. * Fix accessible text for voice commands Using the title attribute means some screenreaders will not be able to show the expanded accessible text at all, but using aria-label loses the hover text currently available. If the title attribute is still used, the accessible label should start with the same content as the visible label. This is necessary for most voice operated tooling which only match starting text. Having "Return" as the start of the accessible label and "Guides" as the start of the visible label means in most cases users that rely on voice commands will not be able to browse here. * Add utilities for screen readers This enables hiding content visually whilst still enabling it for assisistive technologies. * Feature detection for JavaScript functionalities * Add landmarks to all guide pages Landmarks such as header, section, footer, article, and the main content landmark help navigating when using assistive tooling. Since each guide is a self-contained article, a header section with the guide introduction and navigation, a footer section which is not part of the content but a call to action, and the rest can be clearly separated, landmarks here are appropiate. * Make back-to-top work without JavaScript By doing feature detection on animation timeline CSS, the graceful degradation can take care of the visiblity of the back-to-top button. In case no JavaScript is available, it should always be shown. * Enable back-to-top without JavaScript And add an accessible label to the button. It would be better to just show the text back to top underneath the arrow, but this change is again better than not having it at all. * Consistent scrolling behaviour respecting pref Use the preference to detect if a user wants reduced motion and if not enable smooth scrolling. This takes care of the back-to-top smooth scrolling, and also adds it to anchor links. If this is unwanted, the change can be reverted and a matchmedia check should be done in JavaScript instead before smooth scrolling * Add skip links to quickly navigate past navs Skip links are a common practice to allow keyboard and other users to skip past large blocks of content that are present on every page, which in this case are the secondary navigation at the top, the version selector, and the chapter navigation. The skip links only show when focused. * Wrap tables to make them responsive * Make back-to-top link to skip link This allow screen readers to announce something, because linking to an empty fragment or the body element doesn't announce anything usefull. * Fix false positive for broken (skip) link anchor * Add branded selectable color Fixes selecting text in dark mode and brands it for both modes. * Make more info and guides index accessible * Adds aria-controls, which binds the control to the content. * Adds aria-expanded, which signals the current expansion state. * Adds focus handling, which focuses the first link or the button depending on the expansion state. * Adds keyboard closing for the more info button. * Adds outside click tracking to close the expanded content. * Fixes the more info button to not be focusable. * Fix CSS for more info button * Fix dark mode for guide selector * Add accessible label for guide navigator * Only use nav on sub-column if it's actually a nav On the index page the sub-column is not a navigational element and does not contain content that needs to be skipped over. Therefore it should not be a <nav> and not contain a skiplink. Furthermore, the definition list doesn't contain any definitions, thus its role should be removed. * Ignore turbo for in-page skiplinks This ensures the JavaScript doesn't overridde any screenreader behaviour and the resulting fragment is correctly focused as expected. * Use keydown for escape detection When an action should be perceived as fast, or no pause is required before the interaction, keydown should be used and not keyup, which can add (the feeling of a) significant delay. * Fix heading levels It is important that the heading structure (all hx elements) are properly closed, and make sense. They can only ever increment by 1 since the previous heading (and decrement by many). * Presentational picture needs aria-hidden="true" The picture here adds a visual gimmic, but doesn't provide information to the user and thus should be removed from the accessibility tree. * JS-enabled link-as-button should have correct role When JavaScript is enabled, this link turns into a button that expands an element. The change ensures that screenreaders only announce it as such if JavaScript is enabled and applied. * Accessible regions, focusable anchors, cleanup Applied requested changes from review. See PR for discussion about explicitly adding a role="region" https://github.com/rails/rails/pull/51499 * Apply requested changes from review and re-apply after rebase * Adapt the highlight in the navigation side column for the new page structure. Additionally, replace the active class with aria-current="true", which is meant to keep track of what is currently active in a set. Finally, update the implementation of the intersection observer to: * not rely on the viewport height (-95%) * not rely on fixing the highlighted item after click * support both scrolling up and scrolling down * support fast scrolling * Apply review commentary * Fix issues with scrolling behaviour To "restore" the current behaviour on main, a solution was needed for browser-OS combinations that do not allow for two concurrent scrolling elements. Current code on main breaks completely when using scroll-behaviour: smooth (in CSS), and breaks when scrolling back-to-top from the bottom of the page (highlight no longer correct). This commit works around the limitation whilst also enabling the non-smooth scrolled solution for those who want reduced motion. Additionally it has a workaround for a bug on Android, and some defaults for those without JavaScript enabled. * Ensure chapters list is always scrolled after scroll-end Co-authored-by:
Rafael Mendonça França <rafael@rubyonrails.org>
Loading