Skip to content

Commit 9f02726

Browse files
DPC-5177 Button link fix (#2924)
## 🎫 Ticket https://jira.cms.gov/browse/DPC-5177 ## 🛠 Changes Updates button link/handling so that buttons that behaved as links are now just links ```html <form method="GET" action="/some-path"> <button>Click me</button> </form> ``` becomes ```html <a href="/some-path">Click me</a> ``` Also updates `button_to` component handling to set method back to the default of POST to avoid incorrect usage going forward. ## ℹ️ Context We were incorrectly using submit buttons which behave differently than expected than links for screen reader users and those who use assistive technology. This makes links semantically consistent. ## 🧪 Validation Verified during development using Lookbook [A11y check](https://github.com/CMSgov/dpc-app/actions/runs/22684903996/job/65765091219) - This change isn't caught by automated semantic HTML check, so we remain at 11 issues
1 parent 77f4b81 commit 9f02726

20 files changed

+38
-67
lines changed

dpc-portal/app/components/core/button/button_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Button
66
class ButtonComponent < ViewComponent::Base
77
attr_accessor :label, :destination, :method, :additional_classes
88

9-
def initialize(label:, destination:, method: :get, additional_classes: nil, disabled: false)
9+
def initialize(label:, destination:, method: :post, additional_classes: nil, disabled: false)
1010
super
1111
@label = label
1212
@destination = destination

dpc-portal/app/components/core/card/basic_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</div>
77
<div class="flex-align-self-center">
88
<% if @button_params %>
9-
<%= button_to @button_params[:name], @button_params[:path], method: @button_params[:method], class: 'usa-button' %>
9+
<%= link_to @button_params[:name], @button_params[:path], class: 'usa-button' %>
1010
<% end %>
1111
</div>
1212
</div>

dpc-portal/app/components/page/invitations/accept_invitation_component.html.erb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
</ul>
1212
</p>
1313
<%= render Core::Button::ButtonComponent.new(label: 'Verify information',
14-
destination: confirm_organization_invitation_path(@organization, @invitation),
15-
method: :post) %>
14+
destination: confirm_organization_invitation_path(@organization, @invitation)) %>
1615
<% end %>
1716
<% if @invitation.credential_delegate? %>
1817
<p>Your identity has been verified. You can now accept your invite</p>
1918
<%= render Core::Button::ButtonComponent.new(label: 'Accept invite',
20-
destination: register_organization_invitation_path(@organization, @invitation),
21-
method: :post) %>
19+
destination: register_organization_invitation_path(@organization, @invitation)) %>
2220
<% end %>
2321
</div>
2422
</div>

dpc-portal/app/components/page/invitations/ao_flow_fail_component.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<p><%=raw t(key=@text, org_name: @org_name) %></p>
1111
<% 'have to put statement here, as do not have route helper in ViewComponent'
1212
if @reason == :fail_to_proof %>
13-
<%= render Core::Button::ButtonComponent.new(label: 'Go to DPC Portal',
14-
destination: root_url,
15-
method: :get) %>
13+
<%= link_to 'Go to DPC Portal', new_user_session_path, class: 'usa-button margin-bottom-3' %>
1614
<% end %>
1715
</div>

dpc-portal/app/components/page/invitations/invitation_login_component.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
<% end %>
99
</ul>
1010
</p>
11-
<%= button_to login_organization_invitation_url(@invitation.provider_organization, @invitation), class: 'usa-button margin-bottom-1 margin-top-2', data: { turbo: false } do %>
12-
Verify my identity
13-
<% end %>
11+
<%= button_to 'Verify my identity', login_organization_invitation_url(@invitation.provider_organization, @invitation), class: 'usa-button margin-bottom-1 margin-top-2', data: { turbo: false } %>
1412
<div><%= link_to 'How to verify your identity', 'https://login.gov/help/verify-your-identity/how-to-verify-your-identity/', target: :_blank %> <%= link_to 'Login.gov FAQ', 'https://www.login.gov/help/', target: :_blank, class: 'margin-left-2' %></div>
1513
</div>

dpc-portal/app/components/page/invitations/register_component.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<div>
44
<p>Your role as Authorized Official and your organization's Medicare enrollment have been verified.</p>
55
<%= render Core::Button::ButtonComponent.new(label: "Submit registration",
6-
destination: register_organization_invitation_path(@organization, @invitation),
7-
method: :post) %>
6+
destination: register_organization_invitation_path(@organization, @invitation)) %>
87
</div>
98
</div>

dpc-portal/app/components/page/invitations/start_component.html.erb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,8 @@
4444
<% end %>
4545
</ul>
4646
</p>
47-
<%= render Core::Button::ButtonComponent.new(label: 'Begin registration',
48-
destination: accept_organization_invitation_path(@organization, @invitation),
49-
additional_classes: ['start-component-button'],
50-
method: :get) if @invitation.authorized_official? %>
51-
<%= render Core::Button::ButtonComponent.new(label: 'Get Started',
52-
destination: confirm_cd_organization_invitation_path(@organization, @invitation),
53-
additional_classes: ['start-component-button'],
54-
method: :get) if @invitation.credential_delegate? %>
47+
<%= link_to 'Begin registration', accept_organization_invitation_path(@organization, @invitation), class: 'usa-button start-component-button' if @invitation.authorized_official? %>
48+
<%= link_to 'Get Started', confirm_cd_organization_invitation_path(@organization, @invitation), class: 'usa-button start-component-button' if @invitation.credential_delegate? %>
5549
</div>
5650
</div>
5751
</div>

dpc-portal/app/components/page/invitations/success_component.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,5 @@
2323
<% end %>
2424
</ul>
2525
<% end %>
26-
<%= render Core::Button::ButtonComponent.new(label: 'Go to DPC Portal',
27-
destination: root_url,
28-
method: :get) %>
26+
<%= link_to 'Go to DPC Portal', new_user_session_path, class: 'usa-button margin-right-0' %>
2927
</div>

dpc-portal/app/components/page/organization/credentials_component.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div id="credentials">
22
<%= render(Core::Card::BasicComponent.new(text_content: '<h2>Client tokens</h2>',
3-
button_params: { name: 'Generate token', path: new_organization_client_token_path(@organization.path_id), method: :get} )) do %>
3+
button_params: { name: 'Generate token', path: new_organization_client_token_path(@organization.path_id)} )) do %>
44
<div>
55
<p>Client tokens monitor who's accessing the API with your organization credentials.</p>
66
<% if @organization.client_tokens.present? %>
@@ -17,7 +17,7 @@
1717
</div>
1818
<% end %>
1919
<%= render(Core::Card::BasicComponent.new(text_content: '<h2>Public keys</h2>',
20-
button_params: { name: 'Add key', path: new_organization_public_key_path(@organization.path_id), method: :get} )) do %>
20+
button_params: { name: 'Add key', path: new_organization_public_key_path(@organization.path_id) } )) do %>
2121
<div>
2222
<p>Public keys verify that client token requests come from an authorized application.</p>
2323
<% if @organization.public_keys.present? %>
@@ -35,7 +35,7 @@
3535
<% end %>
3636

3737
<%= render(Core::Card::BasicComponent.new(text_content: '<h2>Public IP addresses</h2>',
38-
button_params: { name: 'Add IP', path: new_organization_ip_address_path(@organization.path_id), method: :get} )) do %>
38+
button_params: { name: 'Add IP', path: new_organization_ip_address_path(@organization.path_id)} )) do %>
3939
<div>
4040
<p>Provide a maximum of 8 public IP addresses associated with systems that will access claims data.</p>
4141
<% if @organization.public_ips.present? %>

dpc-portal/app/components/page/organization/new_organization_success_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<div class="margin-top-5">
1717
<div class="display-flex flex-row flex-start" style="gap:20px;">
1818
<div class="flex-align-self-center">
19-
<%= render Core::Button::ButtonComponent.new(label: 'Assign CD now', destination: new_organization_credential_delegate_invitation_path(@organization))%>
19+
<%= link_to 'Assign CD now', new_organization_credential_delegate_invitation_path(@organization), class: 'usa-button margin-right-0' %>
2020
</div>
2121
<div class="flex-align-self-center">
2222
<%= link_to 'Assign CD later', root_path %>

0 commit comments

Comments
 (0)