Skip to content

Commit

Permalink
Add the keyboard shim for link buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-kirwan committed Nov 18, 2022
1 parent d69aa6f commit 28d408e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

* Share links allow data attributes ([PR #3072](https://github.com/alphagov/govuk_publishing_components/pull/3072))
* Update to LUX 304 ([PR #3070](https://github.com/alphagov/govuk_publishing_components/pull/3070))
* Add the keyboard shim for link buttons ([PR #3027](https://github.com/alphagov/govuk_publishing_components/pull/3027))

## 32.1.0

Expand Down
4 changes: 4 additions & 0 deletions lib/govuk_publishing_components/presenters/button_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def initialize(local_assigns)
end
@rel = local_assigns[:rel]
@data_attributes = local_assigns[:data_attributes]
if href.present?
@data_attributes ||= {}
@data_attributes[:module] = ["govuk-button", @data_attributes[:module]].reject(&:blank?).join(" ")
end
@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 28d408e

Please sign in to comment.