Skip to content

Commit

Permalink
Merge pull request #3027 from alphagov/add-the-keyboard-shim-for-link…
Browse files Browse the repository at this point in the history
…-buttons

Add the keyboard shim for link buttons
  • Loading branch information
jon-kirwan authored Nov 29, 2022
2 parents 8a8b49e + 5f9092e commit 18d08d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Add the keyboard shim for link buttons ([PR #3027](https://github.com/alphagov/govuk_publishing_components/pull/3027))

## 33.0.0

* **BREAKING** Refactor GA4 analytics event and link trackers ([PR #3057](https://github.com/alphagov/govuk_publishing_components/pull/3057))
Expand Down
3 changes: 2 additions & 1 deletion lib/govuk_publishing_components/presenters/button_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def initialize(local_assigns)
@info_text_classes << margin_class
end
@rel = local_assigns[:rel]
@data_attributes = local_assigns[:data_attributes]
@data_attributes = local_assigns[:data_attributes]&.symbolize_keys || {}
@data_attributes[:module] = "govuk-button #{data_attributes[:module]}".strip if link?
@margin_bottom = local_assigns[:margin_bottom]
@inline_layout = local_assigns[:inline_layout]
@target = local_assigns[:target]
Expand Down
4 changes: 2 additions & 2 deletions spec/components/button_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def component_name
assert_select ".govuk-button[type=submit]", text: "Submit"

render_component(text: "Link", href: "#", type: "button")
assert_select "a.govuk-button", text: "Link"
assert_select "a.govuk-button[data-module=\"govuk-button\"]", text: "Link"
assert_select "a.govuk-button[type=submit]", false

render_component(text: "Button", type: "button")
Expand Down Expand Up @@ -169,7 +169,7 @@ def component_name
},
)

assert_select "a.govuk-button[data-module='cross-domain-tracking']"
assert_select "a.govuk-button[data-module='govuk-button cross-domain-tracking']"
assert_select "a.govuk-button[data-tracking-code='GA-123ABC']"
assert_select "a.govuk-button[data-tracking-name='transactionTracker']"
end
Expand Down

0 comments on commit 18d08d0

Please sign in to comment.