Skip to content

Commit

Permalink
Add component wrapper to error alert component
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Oct 22, 2024
1 parent ce06c4e commit e2a09b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
id ||= nil
description ||= nil
data_attributes ||= {}

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.set_id(id)
component_helper.add_class("gem-c-error-alert govuk-!-display-none-print")
component_helper.add_data_attribute({ module: "initial-focus" })
component_helper.add_role("alert")
%>
<%= tag.div id: id, class: "gem-c-error-alert govuk-!-display-none-print", data: { module: "initial-focus" }.merge(data_attributes), role: "alert", tabindex: "-1" do %>
<%= tag.div(**component_helper.all_attributes, tabindex: "-1") do %>
<% if description.present? %>
<%= tag.h2 message, class: "gem-c-error-summary__title" %>
<%= tag.div description, class: "gem-c-error-summary__body" %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Error alert
description: Used at the top of the page, to summarise a unsuccessful user action.
uses_component_wrapper_helper: true
accessibility_criteria: |
- should be focused on page load, to ensure the message is noticed by
assistive tech
Expand Down

0 comments on commit e2a09b4

Please sign in to comment.