Skip to content

fix(z-button): render semantic anchors for link role#616

Open
ada-workbackai wants to merge 1 commit intomasterfrom
workbackai/fix/wcag-4.1.2-button-link-role
Open

fix(z-button): render semantic anchors for link role#616
ada-workbackai wants to merge 1 commit intomasterfrom
workbackai/fix/wcag-4.1.2-button-link-role

Conversation

@ada-workbackai
Copy link
Copy Markdown
Contributor

Summary

Fixes WCAG 4.1.2 (Name, Role, Value) by ensuring z-button components with link semantics render as proper anchor elements instead of buttons with role="link".

Issue: When htmlrole="link" or deprecated role="link" was set without an href attribute, the component rendered as a <button> element with role="link". This violates WCAG 4.1.2 because non-semantic elements with ARIA roles must properly implement all required behaviors, keyboard interactions, and properties that native semantic elements provide automatically.

Solution: Modified the z-button component to detect when link role is requested and render as a semantic <a> element. When no href is provided, it defaults to "#" to maintain semantic correctness.

Changes

  • Modified render() method to check for htmlrole="link" or role="link"
  • When link role is detected, component renders as <a> element
  • Anchors without explicit href use "#" as default
  • Removed role attribute from button elements to prevent invalid ARIA usage

Test Plan

  • Component renders as anchor when htmlrole="link" is set
  • Component renders as button when no link role is specified
  • Existing href usage continues to work correctly
  • Keyboard navigation works with Tab and Enter on link-role elements

Evidence

View before/after screenshots and full audit details:
https://app.workback.ai/dashboard/issue/2842/


WCAG Reference:
4.1.2 Name, Role, Value (Level A)

Fixes WCAG 4.1.2 violation where buttons with role="link" were used
instead of semantic anchor elements. When htmlrole or role is set to
"link", the component now renders as an <a> element with proper href
attribute, ensuring native keyboard support and correct assistive
technology behavior.

Changes:
- Modified render() to detect link role and render as anchor
- Anchors without explicit href default to "#"
- Maintains backward compatibility with existing href usage
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.

1 participant