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

Fix login screen accessibility: add form labels, lang attribute, and update link contrast (#1373) #2252

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davidhmnng
Copy link

…update link contrast (#1373)

Description

Added accessibility improvements to the login screen:

  • Added form labels for email and password fields
  • Added lang="en" attribute for proper language identification
  • Updated link color to #0056b3 to meet WCAG AA contrast requirements

Motivation and Context

Fixes #1373
These changes improve accessibility for users relying on screen readers and those with visual impairments by providing proper form labels, language identification, and sufficient color contrast.

How Has This Been Tested?

Tested locally by:

  • Verifying form labels are properly associated with input fields
  • Confirming lang attribute is present in the HTML
  • Checking the new link color meets contrast requirements

Types of changes

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ x] I have run rubocop and erblint for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting
  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

📝 Walkthrough

Walkthrough

The pull request includes updates to two files. The _variables.scss file has modified the $autolab-blue-text variable from #0869af to #0056b3. In the new.html.erb file for Devise sessions, a lang="en" attribute was added to a <div> element, and labels were introduced for the email and password fields to improve accessibility. No other changes were made to the structure or functionality of the form.

Changes

File Change Summary
app/assets/stylesheets/_variables.scss Updated $autolab-blue-text from #0869af to #0056b3
app/views/devise/sessions/new.html.erb Added lang="en" to <div> and labels for email and password fields

Assessment against linked issues

Objective Addressed Explanation
Missing form labels (1373)
Language missing (1373)
Contrast errors (1373) No changes made to link colors or contrast ratio.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
app/views/devise/sessions/new.html.erb (2)

9-12: Consider removing redundant placeholder text

The label implementation looks good and follows accessibility best practices. However, the placeholder text duplicates the label which is redundant. Consider removing the placeholder or using it for format hints instead (e.g., "[email protected]").

-    <%= f.email_field :email, autofocus: true, placeholder: "Email Address" %>
+    <%= f.email_field :email, autofocus: true, placeholder: "[email protected]" %>

13-16: Add password requirements hint for better accessibility

While the label implementation is correct, consider adding password requirements using aria-describedby to help users understand password constraints before submission.

-    <%= f.label :password, "Password" %>
-    <%= f.password_field :password, placeholder: "Password" %>
+    <%= f.label :password, "Password" %>
+    <span id="password-requirements" class="sr-only">Password must be at least 8 characters long</span>
+    <%= f.password_field :password, 
+                        "aria-describedby": "password-requirements",
+                        placeholder: "Enter your password" %>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fe44b53 and 1a2c943.

📒 Files selected for processing (2)
  • app/assets/stylesheets/_variables.scss (1 hunks)
  • app/views/devise/sessions/new.html.erb (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/assets/stylesheets/_variables.scss

Comment on lines +1 to +16
<div class="sign-in-panel home" lang="en">
<br>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>

<img src="/images/autolab.svg" alt="" class="valign login-logo">
<h5>Login to Autolab</h5>

<div><%= f.email_field :email, autofocus: true, placeholder: "Email Address" %></div>
<div><%= f.password_field :password, placeholder: "Password" %></div>
<div>
<%= f.label :email, "Email Address" %>
<%= f.email_field :email, autofocus: true, placeholder: "Email Address" %>
</div>
<div>
<%= f.label :password, "Password" %>
<%= f.password_field :password, placeholder: "Password" %>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Heading structure needs improvement for better accessibility

Based on the search results, the login page's h5 heading appears without any preceding higher-level headings, while the rest of the application follows a more structured heading hierarchy (h1-h4). To maintain consistent and accessible heading structure:

  1. Change <h5>Login to Autolab</h5> to <h1>Login to Autolab</h1> since it's the main heading of the page
  2. Move the language attribute from the sign-in panel to the html element
  3. Add role="main" to the sign-in panel for better landmark navigation

Example:

<div class="sign-in-panel home" role="main">
  <br>
  <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
    <img src="/images/autolab.svg" alt="" class="valign login-logo">
    <h1>Login to Autolab</h1>
    ...
🔗 Analysis chain

Additional accessibility improvements to consider

While the current changes improve accessibility, consider these additional enhancements:

  1. Improve the heading structure - either add higher-level headings or change h5 to h1
  2. Restructure the remember me checkbox to use proper label association instead of wrapping with <label>
  3. Add role="main" to the main content area

Let's check the current heading structure:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for heading elements in the views
rg "<h[1-6]" app/views/

Length of output: 21123

@@ -1,13 +1,19 @@
<div class="sign-in-panel home">
<div class="sign-in-panel home" lang="en">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Potential issue

Move lang attribute from div to HTML element in layout files

The lang attribute should be moved from the div to the <html> element in both layout files:

  • app/views/layouts/application.html.erb
  • app/views/layouts/doorkeeper/application.html.erb

This ensures proper language identification for the entire document and better compliance with WCAG guidelines. Remove the lang attribute from the div in app/views/devise/sessions/new.html.erb once added to the layout files.

🔗 Analysis chain

Move lang attribute to the HTML element

While adding the lang attribute is a step in the right direction, it should be placed on the <html> element rather than a <div>. This ensures proper language identification for the entire document and better compliance with WCAG guidelines.

Let's verify if the layout file already has a lang attribute:


The output shows that there are two layout files containing <html> tags, and neither of them has the lang attribute. Let me verify if these are the only layout files and their complete paths to provide accurate feedback.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the application layout file and check for lang attribute
fd --type f "application.html" --exec cat {} \; | grep -A 5 "<html"

Length of output: 504


Script:

#!/bin/bash
# Get complete paths of layout files
fd --type f "application.html"

Length of output: 119

@ogometz
Copy link

ogometz commented Dec 9, 2024

Hi David, it looks like all the checks have passed on your PR. It's great that you are making changes that makes the website more accessible. One thing that might be nice for you to add is to explain how you know the updated color adheres to the AA guidelines. Otherwise, it looks like you've address all three pain points outlined in the issue. The language is specified, you have modified the color to adhere to AA guidelines, and the email and password fields now have labels for voice navigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Login screen accessibility issues
2 participants