From 457ce32db0b9eb52a20f8e88f30be471f9292b6c Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 10 Apr 2025 12:34:10 -0400 Subject: [PATCH 1/3] Migrate from jQuery.click --- fec/fec/static/js/modules/audit_tags.js | 4 ++-- fec/fec/static/js/modules/calendar.js | 2 +- fec/fec/static/js/modules/dropdowns.js | 2 +- fec/fec/static/js/modules/filters/filter-set.js | 2 +- fec/fec/templates/404.html | 3 +-- fec/fec/templates/500.html | 3 +-- fec/fec/tests/js/calendar.js | 6 +++--- fec/fec/tests/js/checkbox-filter.js | 2 +- fec/fec/tests/js/contact-form.js | 2 +- fec/fec/tests/js/dropdowns.js | 14 +++++++------- fec/fec/tests/js/tables.js | 2 +- 11 files changed, 20 insertions(+), 22 deletions(-) diff --git a/fec/fec/static/js/modules/audit_tags.js b/fec/fec/static/js/modules/audit_tags.js index c1b1edd26a..786deffcc2 100644 --- a/fec/fec/static/js/modules/audit_tags.js +++ b/fec/fec/static/js/modules/audit_tags.js @@ -20,12 +20,12 @@ export default function auditTags() { $('.tag__item.sub').contents()[0].nodeValue = `Sub Category: ${current_sub}`; }); - $('.js-close_sub').click(function() { // TODO: jQuery deprecation + $('.js-close_sub').on('click', function() { $('#primary_category_id').trigger('change'); $('#sub_category_id').val('all'); }); - $('.js-close_primary').click(function() { // TODO: jQuery deprecation + $('.js-close_primary').on('click', function() { $('#primary_category_id').val('all'); $('#primary_category_id').trigger('change'); $('.tag__item.primary button').hide(); diff --git a/fec/fec/static/js/modules/calendar.js b/fec/fec/static/js/modules/calendar.js index bdda2ea1cb..d248820193 100644 --- a/fec/fec/static/js/modules/calendar.js +++ b/fec/fec/static/js/modules/calendar.js @@ -339,7 +339,7 @@ Calendar.prototype.handleEventClick = function(calEvent, jsEvent) { // Simulate clicks when hitting enter on certain full-calendar elements Calendar.prototype.simulateClick = function(e) { if (e.keyCode === 13) { - $(e.target).click(); // TODO: jQuery deprecation + $(e.target).trigger('click'); } }; diff --git a/fec/fec/static/js/modules/dropdowns.js b/fec/fec/static/js/modules/dropdowns.js index 0d1c0762f1..dc2910b8a8 100644 --- a/fec/fec/static/js/modules/dropdowns.js +++ b/fec/fec/static/js/modules/dropdowns.js @@ -145,7 +145,7 @@ Dropdown.prototype.handleDropdownItemClick = function(e) { const $input = this.$selected.find('#' + $button.data('label')); if (!$button.hasClass('is-checked')) { - $input.click(); // TODO: jQuery deprecation + $input.trigger('click'); } }; diff --git a/fec/fec/static/js/modules/filters/filter-set.js b/fec/fec/static/js/modules/filters/filter-set.js index c7f1e3829c..bc1108b604 100644 --- a/fec/fec/static/js/modules/filters/filter-set.js +++ b/fec/fec/static/js/modules/filters/filter-set.js @@ -166,7 +166,7 @@ FilterSet.prototype.handleTagRemoved = function(e, opts) { const type = $input.get(0).type; if (type === 'checkbox' || type === 'radio') { - $input.click(); // TODO: jQuery deprecation + $input.trigger('click'); } else if (type === 'text') { $input.val(''); $input.get(0).dispatchEvent(new Event('change', { bubbles: true })); diff --git a/fec/fec/templates/404.html b/fec/fec/templates/404.html index 33caac1a3e..368385762c 100644 --- a/fec/fec/templates/404.html +++ b/fec/fec/templates/404.html @@ -7,8 +7,7 @@

Page not found

Sorry, we couldn't find the page you're looking for.

- {# TODO: jQuery deprecation of .click() #} -

We work hard to keep our URLs up to date, but please let us know if you think something is missing or broken. Use the feedback box on the bottom of any page or contact the FEC.

+

We work hard to keep our URLs up to date, but please let us know if you think something is missing or broken. Use the feedback box on the bottom of any page or contact the FEC.

diff --git a/fec/fec/templates/500.html b/fec/fec/templates/500.html index dcc3d79d7c..85c0f8c529 100644 --- a/fec/fec/templates/500.html +++ b/fec/fec/templates/500.html @@ -7,9 +7,8 @@

Server error

- {# TODO: jQuery deprecation of .click() #}

Sorry, this page failed to load. Check the FEC’s API status page to see if we are experiencing a temporary outage. If not, please try again, and thanks for your patience.

-

If you'd like to contact our team, use the feedback box on the bottom of any page or contact the FEC.

+

If you'd like to contact our team, use the feedback box on the bottom of any page or contact the FEC.

diff --git a/fec/fec/tests/js/calendar.js b/fec/fec/tests/js/calendar.js index 05a0bd916b..49797b1837 100644 --- a/fec/fec/tests/js/calendar.js +++ b/fec/fec/tests/js/calendar.js @@ -250,17 +250,17 @@ describe('calendar tooltip', function() { }); it('closes on click away', function() { - $(document.body).click(); // TODO: jQuery deprecation + $(document.body).trigger('click'); expect($('.cal-details').length).to.equal(0); }); it('stays open if you click inside it', function() { - this.calendarTooltip.$content.find('a').click(); // TODO: jQuery deprecation + this.calendarTooltip.$content.find('a').trigger('click'); expect($('.cal-details').length).to.equal(1); }); it('closes on clicking the close button', function() { - this.calendarTooltip.$content.find('.js-close').click(); // TODO: jQuery deprecation + this.calendarTooltip.$content.find('.js-close').trigger('click'); expect($('.cal-details').length).to.equal(0); }); diff --git a/fec/fec/tests/js/checkbox-filter.js b/fec/fec/tests/js/checkbox-filter.js index b47a0c5902..7fb486016e 100644 --- a/fec/fec/tests/js/checkbox-filter.js +++ b/fec/fec/tests/js/checkbox-filter.js @@ -136,7 +136,7 @@ describe('checkbox filters', function() { }); it('removes checkbox on clicking the button', function() { - this.filter.$elm.find('.js-remove').click(); // TODO: jQuery deprecation + this.filter.$elm.find('.js-remove').trigger('click'); expect(this.filter.$elm.find('li').length).to.equal(0); }); diff --git a/fec/fec/tests/js/contact-form.js b/fec/fec/tests/js/contact-form.js index 06f0dead59..7dac5349e7 100644 --- a/fec/fec/tests/js/contact-form.js +++ b/fec/fec/tests/js/contact-form.js @@ -82,7 +82,7 @@ describe('Contact form', function() { $('#id_u_committee').val('12345'); $('#id_u_other_reason').val('Some other reason'); $('select').val('other'); - this.form.$cancel.click(); // TODO: jQuery deprecation + this.form.$cancel.trigger('click'); expect(this.form.committeeId.val()).to.equal(''); expect($('select').val()).to.equal(null); expect($('#id_u_other_reason').val()).to.equal(''); diff --git a/fec/fec/tests/js/dropdowns.js b/fec/fec/tests/js/dropdowns.js index 2c89bca298..ecb8d5e862 100644 --- a/fec/fec/tests/js/dropdowns.js +++ b/fec/fec/tests/js/dropdowns.js @@ -65,15 +65,15 @@ describe('dropdown', function() { }); it('toggles', function() { - this.dropdown.$button.click(); // TODO: jQuery deprecation + this.dropdown.$button.trigger('click'); expect(isOpen(this.dropdown)).to.be.true; - this.dropdown.$button.click(); // TODO: jQuery deprecation + this.dropdown.$button.trigger('click'); expect(isClosed(this.dropdown)).to.be.true; }); it('handles a check', function() { var checkbox = this.dropdown.$panel.find('#A'); - checkbox.click(); // TODO: jQuery deprecation + checkbox.trigger('click'); expect(checkbox.is(':checked')).to.be.true; }); @@ -103,8 +103,8 @@ describe('dropdown', function() { it('unchecks an input', function() { var checkbox = this.dropdown.$panel.find('#B'); - checkbox.click(); // TODO: jQuery deprecation - checkbox.click(); // TODO: jQuery deprecation + checkbox.trigger('click'); + checkbox.trigger('click'); var dropdownItem = this.dropdown.$panel.find('.dropdown__item--selected'); expect(dropdownItem.hasClass('is-checked')).to.be.false; }); @@ -121,8 +121,8 @@ describe('dropdown', function() { it('removes an unchecked input', function() { var checkbox = this.dropdown.$panel.find('#B'); - checkbox.click(); // TODO: jQuery deprecation - checkbox.click(); // TODO: jQuery deprecation + checkbox.trigger('click'); + checkbox.trigger('click'); expect(checkbox.is(':checked')).to.be.false; this.dropdown.handleCheckboxRemoval(checkbox); var selectedItems = this.dropdown.$selected.find('.dropdown__item'); diff --git a/fec/fec/tests/js/tables.js b/fec/fec/tests/js/tables.js index a6013466b7..de7259d36b 100644 --- a/fec/fec/tests/js/tables.js +++ b/fec/fec/tests/js/tables.js @@ -106,7 +106,7 @@ describe('data table', function() { }); it('does nothing on click', function() { - this.table.$exportButton.click(); // TODO: jQuery deprecation + this.table.$exportButton.trigger('click'); expect(DataTable_FEC.prototype.export).not.to.have.been.called; }); }); From 776d36cb962c8c6453e4569b2c22b796bef636ed Mon Sep 17 00:00:00 2001 From: John Carroll Date: Tue, 17 Jun 2025 11:21:55 -0400 Subject: [PATCH 2/3] resolve merge conflict --- fec/fec/static/js/modules/filters/filter-set.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fec/fec/static/js/modules/filters/filter-set.js b/fec/fec/static/js/modules/filters/filter-set.js index bc1108b604..3da4f187cc 100644 --- a/fec/fec/static/js/modules/filters/filter-set.js +++ b/fec/fec/static/js/modules/filters/filter-set.js @@ -167,7 +167,7 @@ FilterSet.prototype.handleTagRemoved = function(e, opts) { if (type === 'checkbox' || type === 'radio') { $input.trigger('click'); - } else if (type === 'text') { + } else if (type === 'text' || type === 'select-one') { $input.val(''); $input.get(0).dispatchEvent(new Event('change', { bubbles: true })); } else if (type === 'select-one') { From fc00ed5a434977b3cfa9953fce58735da4f5b6c8 Mon Sep 17 00:00:00 2001 From: John Carroll Date: Tue, 17 Jun 2025 11:41:11 -0400 Subject: [PATCH 3/3] fix formatting for conditional --- fec/fec/static/js/modules/filters/filter-set.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fec/fec/static/js/modules/filters/filter-set.js b/fec/fec/static/js/modules/filters/filter-set.js index 677823cc8a..c6407755b2 100644 --- a/fec/fec/static/js/modules/filters/filter-set.js +++ b/fec/fec/static/js/modules/filters/filter-set.js @@ -165,8 +165,9 @@ FilterSet.prototype.handleTagRemoved = function(e, opts) { if ($input.length > 0) { const type = $input.get(0).type; - if (type === 'checkbox' || type === 'radio') $input.trigger('click'); - else if (type === 'text' || type === 'select-one') { + if (type === 'checkbox' || type === 'radio') { + $input.trigger('click'); + } else if (type === 'text' || type === 'select-one') { $input.val(''); $input.get(0).dispatchEvent(new Event('change', { bubbles: true })); }