Skip to content

Commit

Permalink
Fix markup (and therefore styling) of RTL history mode banner
Browse files Browse the repository at this point in the history
Right-to-left languages were displaying the government name in
an unusual way, treating the government name as translated text
even though it is still English. This commit fixes the text
direction, as well as setting the correct language for the text
snippet.

Before:
![to 2024 Sunak Conservative government 2022](https://github.com/user-attachments/assets/999781ba-8f6e-4c03-8f6d-00d9b8921c4c)

After:
![2022 to 2024 Sunak Conservative government](https://github.com/user-attachments/assets/d94c7979-03f3-46ca-bc97-4a86951a8b31)
  • Loading branch information
ChrisBAshton committed Oct 1, 2024
1 parent 8113059 commit a5425a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/views/shared/_history_notice.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<% if content_item.historically_political? %>
<%= render "govuk_publishing_components/components/notice", {
title: t("shared.historically_political", government: content_item.publishing_government),
title: sanitize(
t("shared.historically_political", government: "<span lang='en' dir='ltr'>#{content_item.publishing_government}</span>"),
attributes: %w(lang dir),
),
} %>
<% end %>
8 changes: 8 additions & 0 deletions test/integration/news_article_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ class NewsArticleTest < ActionDispatch::IntegrationTest
end
end

test "marks up government name correctly" do
setup_and_visit_content_item("news_article_history_mode_translated_arabic")

within ".govuk-notification-banner__content" do
assert page.has_css?("span[lang='en'][dir='ltr']", text: "2022 to 2024 Sunak Conservative government")
end
end

test "does not render with the single page notification button" do
setup_and_visit_content_item("news_article")
assert_not page.has_css?(".gem-c-single-page-notification-button")
Expand Down

0 comments on commit a5425a7

Please sign in to comment.