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 15, 2022
1 parent 1d9128f commit b2b62a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
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))

## 32.1.0

* Calculate viewport width correctly for navbar in Chrome and Firefox when Mac scrollbars are enabled ([PR #3016](https://github.com/alphagov/govuk_publishing_components/pull/3016))
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 b2b62a4

Please sign in to comment.