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(NcAvatar): Remove span wrapper button semantics in favour of internal button components #5131

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

Pytal
Copy link
Contributor

@Pytal Pytal commented Jan 25, 2024

☑️ Resolves

Summary

Previous iteration
  • Previously the tab sequence would go from wrapper span[role="button"] -> action menu button -> next element on page. Only the span focus would show visual focus while the action menu button had none so there would appear to be a gap in the tab sequence.
  • W3 states that "a button element allows phrasing content as descendants, and does not allow interactive content or descendants with a tabindex attribute. Therefore, any elements specified with a role=button would follow the same descendant restrictions, and not allow any interactive content descendants, elements with a tabindex specified, or any elements with role values that are in the interactive content category" -https://www.w3.org/TR/html-aria/#allowed-descendants-of-aria-roles
  • The buttons inside span[role="button"] would be classified as interactive content and so is invalid HTML
  • Setting tabindex="-1" would violate the above requirement and only removes sequential focus but not focusability via click or programmatic .focus()
  • The NcAvatar wrapper span acts as a button with role="button" + event listeners and for the purposes of this component should be the only interative element which programmatically activates NcActions. This makes direct interaction on the NcActions button redundant.
  • All descendants of a role="button" element implictly have role="presenation" but because browsers ignore role="presentation" on focusable elements (the buttons) we have to set inert explicitly
  • This inert fix corrects the invalid HTML and removes redundant behaviour
  • Remove button semantics from span wrapper
  • Fixes focus return on Escape from menu
  • Uses button semantics from internal button components

🏁 Checklist

  • ⛑️ Tests are included or are not applicable
  • 📘 Component documentation has been extended, updated or is not applicable

@Pytal Pytal added bug Something isn't working 3. to review Waiting for reviews feature: avatar Related to the avatar component accessibility Making sure we design for the widest range of people possible, including those who have disabilities labels Jan 25, 2024
@Pytal Pytal added this to the 8.5.1 milestone Jan 25, 2024
@Pytal Pytal self-assigned this Jan 25, 2024
@ShGKme

This comment was marked as resolved.

@ShGKme

This comment was marked as resolved.

@Pytal

This comment was marked as resolved.

@ShGKme

This comment was marked as resolved.

Copy link
Contributor

@JuliaKirschenheuter JuliaKirschenheuter left a comment

Choose a reason for hiding this comment

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

Thanks Chris for cleaning this up!

Works! One question: could we return a focus to the avatar (action button) when action menu is closed? Or is it another issue?

artonge

This comment was marked as resolved.

@emoral435

This comment was marked as resolved.

Copy link
Contributor

@emoral435 emoral435 left a comment

Choose a reason for hiding this comment

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

Both solutions proposed works, all just a matter of preference 👍

@Pytal

This comment was marked as resolved.

@ShGKme

This comment was marked as resolved.

@Pytal Pytal force-pushed the fix/actions-focus-in-avatar branch from 1ee2040 to c94784c Compare January 26, 2024 22:07
@Pytal Pytal changed the title fix(NcAvatar): Fix invalid interactive content in avatar fix(NcAvatar): Remove span wrapper button semantics in favour of internal button components Jan 26, 2024
@Pytal
Copy link
Contributor Author

Pytal commented Jan 26, 2024

Moved the button semantics to the actual buttons rather than the wrapper span while preserving the same UX as before (slightly strange NcActions click triggering toggleMenu to fetch the latest contactsmenu data)

@Pytal Pytal mentioned this pull request Jan 26, 2024
Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

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

Looks much better to me!

@Pytal Pytal merged commit dceef1e into master Jan 26, 2024
16 checks passed
@Pytal Pytal deleted the fix/actions-focus-in-avatar branch January 26, 2024 22:42
Copy link
Contributor

@Antreesy Antreesy left a comment

Choose a reason for hiding this comment

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

Seems legit, tested listeners and new template

src/components/NcAvatar/NcAvatar.vue Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews accessibility Making sure we design for the widest range of people possible, including those who have disabilities bug Something isn't working feature: avatar Related to the avatar component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants