Skip to content

Commit

Permalink
Remove redundant role attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-kirwan committed Jan 15, 2025
1 parent 6494163 commit 9528fa5
Show file tree
Hide file tree
Showing 15 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
component_helper.add_class("gem-c-contents-list--custom-title") if title
component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4
component_helper.add_aria_attribute({ label: t("components.contents_list.contents") }) unless local_assigns[:aria][:label]
component_helper.add_role("navigation")

title_fallback = t("components.contents_list.contents", locale: I18n.locale, fallback: false, default: "en")
%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
service_navigation_aria_label ||= "Service menu"
%>

<header class="gem-c-cross-service-header" role="banner" data-module="cross-service-header">
<header class="gem-c-cross-service-header" data-module="cross-service-header">
<%= render "govuk_publishing_components/components/cross_service_header/one_login_header", {
one_login_navigation_items: one_login_navigation_items,
} %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-layout-footer govuk-footer")
component_helper.add_class("gem-c-layout-footer--border") if with_border
component_helper.add_role("contentinfo")
component_helper.add_data_attribute({ module: "ga4-link-tracker" })
%>
<%= tag.footer(**component_helper.all_attributes) do %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
component_helper.add_class("gem-c-layout-header govuk-header")
component_helper.add_class("gem-c-layout-header--#{environment}") if environment
component_helper.add_class("gem-c-layout-header--no-bottom-border") if remove_bottom_border
component_helper.add_role("banner")
component_helper.add_data_attribute({ module: "govuk-header" })

%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-layout-super-navigation-header")
component_helper.add_class("gem-c-layout-super-navigation-header--blue-background") if blue_background
component_helper.add_role("banner")
component_helper.add_data_attribute({ module: "ga4-event-tracker ga4-link-tracker", ga4_expandable: "" })
%>
<%= tag.header(**component_helper.all_attributes) do %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("govuk-pagination govuk-pagination--block")
component_helper.add_role("navigation")
component_helper.add_aria_attribute({ label: t("components.previous_and_next_navigation.pagination") })
component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
component_helper.add_aria_attribute({label: aria_label})
component_helper.add_class('gem-c-secondary-navigation')
component_helper.set_id(id)
component_helper.add_role("navigation")
%>

<% if items.any? %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
translation_helper = GovukPublishingComponents::Presenters::TranslationNavHelper.new(local_assigns)

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_role("navigation")
component_helper.add_class("gem-c-translation-nav govuk-!-display-none-print #{translation_helper.classes} #{brand_helper.brand_class}")
component_helper.add_aria_attribute({ label: t("common.translations") })
%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="govuk-grid-column-two-thirds">
<div id="wrapper">
<%= yield :before_content %>
<main role="main" id="content">
<main id="content">
<%= yield %>
</main>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<nav role="navigation"
class="gem-c-related-navigation__nav-section"
<nav class="gem-c-related-navigation__nav-section"
aria-labelledby="related-nav-<%= section_title %>-<%= random %>"
data-module="gem-toggle">

Expand Down
2 changes: 1 addition & 1 deletion spec/components/previous_and_next_navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def component_name
label: "1 of 3",
})

assert_select ".govuk-pagination[role='navigation']"
assert_select ".govuk-pagination"
assert_select ".govuk-pagination__link-title", text: "Previous page"
assert_select ".govuk-pagination__link-label", text: "1 of 3"
assert_link("previous-page")
Expand Down
2 changes: 1 addition & 1 deletion spec/components/translation_nav_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def multiple_translations

it "is labelled as translation navigation" do
render_component(translations: multiple_translations)
assert_select "nav[role='navigation'][aria-label='Translations']"
assert_select "nav[aria-label='Translations']"
end

it "adds branding correctly" do
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/app/views/layouts/dummy_admin_layout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}%>
<div class="govuk-width-container">
<%# breadcrumbs, backlink, phasebanner goes here %>
<main class="govuk-main-wrapper " id="main-content" role="main">
<main class="govuk-main-wrapper " id="main-content">
<%= yield %>
</main>
</div>
Expand Down
2 changes: 1 addition & 1 deletion spec/javascripts/components/cross-service-header-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('The _layout_header_one_login', function () {
beforeEach(function () {
container = document.createElement('div')
container.innerHTML =
'<header class="gem-c-cross-service-header" role="banner" data-module="cross-service-header">' +
'<header class="gem-c-cross-service-header" data-module="cross-service-header">' +
'<div class="gem-c-one-login-header" data-one-login-header-nav>' +
'<div class="gem-c-one-login-header__container govuk-width-container">' +
'<div class="gem-c-one-login-header__logo">' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
aria: {
labelledby: "element",
},
role: "navigation",
role: "region",
lang: "en",
open: true,
hidden: "",
Expand All @@ -28,7 +28,7 @@
aria: {
labelledby: "element",
},
role: "navigation",
role: "region",
lang: "en",
open: true,
hidden: "",
Expand Down Expand Up @@ -194,19 +194,19 @@
}.to raise_error(ArgumentError, error)

expect {
GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(role: "navigation custarddoughnuts moose")
GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(role: "region custarddoughnuts moose")
}.to raise_error(ArgumentError, error)
end

it "does not accept an invalid role when passed" do
error = "Role attribute (custarddoughnuts, moose) is not recognised"
expect {
helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(role: "navigation")
helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(role: "region")
helper.add_role("custarddoughnuts moose")
}.to raise_error(ArgumentError, error)

expect {
helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(role: "navigation")
helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(role: "region")
helper.add_role("alert custarddoughnuts moose")
}.to raise_error(ArgumentError, error)
end
Expand Down

0 comments on commit 9528fa5

Please sign in to comment.