Skip to content

Commit

Permalink
removal of in line JS (#4876)
Browse files Browse the repository at this point in the history
* removal of in line JS

* changed element name
  • Loading branch information
anncaballeroo authored and bbodine1 committed Dec 24, 2024
1 parent e9ee47a commit d5a5c35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
7 changes: 7 additions & 0 deletions app/assets/javascripts/keyboard_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ function handleContactInfoKeyDown(event, radioId, modifyDiv) {
}
}

$(document).on('keydown', '.plan-contact-info-alt', function (event) {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
document.getElementById($(this).data('contact-click-id')).click();
}
});

document.addEventListener('turbolinks:load', () => {
// Use event propogation to handle `Enter` keydown events for HTML elements with the attribute `data-keydown-id`.
// Using event propogation is mainly a workaround for FA Income pages, which load income forms by cloning dummy hidden forms.
Expand Down
13 changes: 2 additions & 11 deletions app/views/insured/families/_enrollment_refactored.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@
<%= render partial: "shared/plan_shoppings/sbc_link", locals: { plan: product, custom_css: false, hbx_id: hbx_enrollment.hbx_id } %>
<% unless details_page %>
<a
class="ml-4"
class="ml-4 plan-contact-info-alt"
id="plan_contact_info-<%= hbx_enrollment.hbx_id%>"
data-toggle="modal"
data-target="#<%= product.kind.to_s %>-<%= product.id %>-<%= hbx_enrollment.hbx_id%>"
tabindex="0"
href="#"
onkeydown="handleContactInfoKeyDownAlt(event, 'plan_contact_info-<%= hbx_enrollment.hbx_id%>', '#<%= product.kind.to_s %>-<%= product.id %>-<%= hbx_enrollment.hbx_id%>')"
data-contact-click-id="plan_contact_info-<%= hbx_enrollment.hbx_id%>"
>

<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
Expand All @@ -141,15 +141,6 @@
</div>
</div>
</div>

<script>
function handleContactInfoKeyDownAlt(event, id, modalId) {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
document.getElementById(id).click();
}
}
</script>
<% else %>
<div class="hbx-enrollment-refactored-panel plan-tile panel panel-default module <%= "initially_hidden_enrollment hidden" if initially_hide_enrollment?(hbx_enrollment) %>">
<div class="plan-header">
Expand Down

0 comments on commit d5a5c35

Please sign in to comment.