x-govuk / govuk-components

Lightweight Ruby on Rails components for developing with the GOV.UK Design System.
https://govuk-components.netlify.app
MIT License
152 stars 20 forks source link

Can’t change role value on a notification banner #109

Closed paulrobertlloyd closed 3 years ago

paulrobertlloyd commented 3 years ago

I’m looking to use the new notification component, and show a success message after a user has successful completed a task. The design system, says this:

Since you’re using the notification banner to tell the user about the outcome of something they’ve just done, add role="alert" so focus shifts to the notification banner on page load.

However, as far as I can tell, this value is hard coded to region: https://github.com/DFE-Digital/govuk-components/blob/e963f4749572f6ae8668adcc64b3db24e6f92f50/app/components/govuk_component/notification_banner.html.erb#L1

Have I understood this correctly? Does this advice also not conflict somewhat with the disable_auto_focus option? (I’m not sure if role="alert" should always mean attracting focus on page load, but this seems reasonable).

peteryates commented 3 years ago

D'oh, this is a bug purely caused by the poor ordering of the arguments in that tag.div call.

Once #110 has been released you'll be able to set the role via the html_attributes, so something like:

render GovukComponent::NotificationBanner.new(title: "omg", html_attributes: { role: "marquee" })
paulrobertlloyd commented 3 years ago

Amazing turnaround! A++++, will file bugs again 😉 Thanks @peteryates!