Skip to content

Commit

Permalink
Revert "Merge pull request #849 from alphagov/prevent-double-click-on…
Browse files Browse the repository at this point in the history
…-buttons"

This reverts commit 19cc9d0, reversing
changes made to 9f259ca.

Previously we changed the button component to automatically prevent
double click for submit-type buttons. This caused an unexpected testing
issue in a consuming app (Content Publisher) in the context of a modal,
where multiple buttons are clicked in succession without a page reload.

This reverts the change to automatically prevent double click, pending
an iteration to the logic in govuk-frontend to scope the prevention to
the same button.
  • Loading branch information
Ben Thorner committed May 17, 2019
1 parent 8013d65 commit 5fe8432
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ body: |
These instances of buttons are added by Content Designers, ideally this duplication would not exist but we currently don't have shared markup
via our components within the generated [govspeak](https://github.com/alphagov/govspeak).
(This is a challenge to the reader)
Buttons with type submit (implicitly defined of unset) are enhanced to [prevent them from being double clicked](https://github.com/alphagov/govuk-frontend/commit/884e7dd73ad943d71fb701da15626e6a7ad0b933).
accessibility_criteria: |
The button must:
Expand Down
3 changes: 1 addition & 2 deletions lib/govuk_publishing_components/presenters/button_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def initialize(local_assigns)
@title = local_assigns[:title]
@info_text = local_assigns[:info_text]
@rel = local_assigns[:rel]
@default_data_attributes = { "prevent-double-click" => true }
@data_attributes = local_assigns[:data_attributes]
@margin_bottom = local_assigns[:margin_bottom]
@inline_layout = local_assigns[:inline_layout]
Expand All @@ -33,7 +32,7 @@ def html_options
options[:role] = "button" if link?
options[:type] = button_type
options[:rel] = rel if rel
options[:data] = button_type == "submit" ? data_attributes.to_h.merge(@default_data_attributes) : data_attributes
options[:data] = data_attributes if data_attributes
options[:title] = title if title
options[:target] = target if target
options
Expand Down
28 changes: 1 addition & 27 deletions spec/components/button_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,7 @@ def component_name
assert_select ".govuk-button.gem-c-button--bottom-margin", text: "Submit"
end

it "renders the default data attribute for buttons" do
render_component(
text: "Submit",
)

assert_select "button.govuk-button[data-prevent-double-click='true']"
end

it "renders the default data attribute for submit buttons" do
render_component(
text: "Submit",
type: "submit"
)

assert_select "button.govuk-button[data-prevent-double-click='true']"
end

it "doesn't render the default data attribute for buttons with type button" do
render_component(
text: "Submit",
type: "button"
)

assert_select "button.govuk-button[data-prevent-double-click='true']", false
end

it "renders custom data attributes correctly for buttons" do
it "renders data attributes correctly for buttons" do
render_component(
text: "Submit",
data_attributes: {
Expand Down

0 comments on commit 5fe8432

Please sign in to comment.