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

[PHX-1317] Ensure a consistent experience for Nri.Block for Screen Readers #1580

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion component-catalog/src/Examples/UiIcon.elm
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ all =
, ( "star", UiIcon.star, [] )
, ( "starFilled", UiIcon.starFilled, [] )
, ( "starOutline", UiIcon.starOutline, [] )
, ( "no", UiIcon.no, [])
, ( "no", UiIcon.no, [] )
]
)
, ( "Badges & Celebration"
Expand Down
14 changes: 8 additions & 6 deletions src/Nri/Ui/Mark/V5.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Nri.Ui.Mark.V5 exposing
### Patch changes:

- Fix line-height for spacer element reducing the amount of vertical space consumed by the balloons
- Fix SR experience for <mark> tags


### Changes from V4
Expand All @@ -23,6 +24,7 @@ module Nri.Ui.Mark.V5 exposing
-}

import Accessibility.Styled.Aria as Aria
import Accessibility.Styled.Role as Role
import Accessibility.Styled.Style exposing (invisibleStyle)
import Content
import Css exposing (Color, Style)
Expand Down Expand Up @@ -279,9 +281,9 @@ viewMarkedByBalloon :
-> Html msg
viewMarkedByBalloon config markedWith segments =
Html.mark
[ markedWith.name
|> Maybe.map (\name -> Aria.roleDescription (stripMarkdownSyntax name ++ " highlight"))
|> Maybe.withDefault AttributesExtra.none
[ -- Drop the `mark` role as various screen readers interpret it differently.
-- Instead we offer additional invisible and accessible content to denote the highlight.
Role.presentation
, css [ Css.backgroundColor Css.transparent, Css.position Css.relative ]
]
-- the balloon should never end up on a line by itself, so we put it in the DOM
Expand All @@ -301,9 +303,9 @@ viewMarkedByBalloon config markedWith segments =
viewMarked : TagStyle -> Mark -> List (Html msg) -> Html msg
viewMarked tagStyle markedWith segments =
Html.mark
[ markedWith.name
|> Maybe.map (\name -> Aria.roleDescription (stripMarkdownSyntax name ++ " highlight"))
|> Maybe.withDefault AttributesExtra.none
[ -- Drop the `mark` role as various screen readers interpret it differently.
-- Instead we offer additional invisible and accessible content to denote the highlight.
Role.presentation
, css
[ Css.backgroundColor Css.transparent
, Css.Global.children
Expand Down
3 changes: 0 additions & 3 deletions tests/Spec/Nri/Ui/Block.elm
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ labelMarkdownSpec =
-- should not include markdown (e.g., no asterisks)
, hasBefore "start This is markdown" "Hello"
, hasAfter "end This is markdown" "there"

-- The roledescription should also not include markdown special characters
, Query.has [ Selector.attribute (Aria.roleDescription "This is markdown highlight") ]
]
]

Expand Down
Loading