From caad689de6c79c73e98523d6fb124c2a2abc96ab Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 11 Apr 2025 08:51:05 -0400 Subject: [PATCH 1/2] Migrate jQuery.blur --- fec/fec/static/js/pages/contact-form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fec/fec/static/js/pages/contact-form.js b/fec/fec/static/js/pages/contact-form.js index e46aab7aaa..7020486d99 100644 --- a/fec/fec/static/js/pages/contact-form.js +++ b/fec/fec/static/js/pages/contact-form.js @@ -44,7 +44,7 @@ ContactForm.prototype.initTypeahead = function() { //...another field, Attempts to focusout, or focus onto body, did not work. $('#id_u_contact_title') .focus() // TODO: jQuery deprecation - .blur(); // TODO: jQuery deprecation + .trigger('blur'); }); }; From 0edfea0c26380961e00aa49a5e9474e947089da7 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 11 Apr 2025 08:51:42 -0400 Subject: [PATCH 2/2] Migrate jQuery.focus --- fec/fec/static/js/modules/calendar-tooltip.js | 2 +- fec/fec/static/js/modules/calendar.js | 4 ++-- fec/fec/static/js/modules/download.js | 2 +- fec/fec/static/js/modules/dropdowns.js | 10 +++++----- fec/fec/static/js/modules/filters/date-filter.js | 2 +- fec/fec/static/js/modules/filters/filter-panel.js | 4 ++-- fec/fec/static/js/modules/filters/filter-typeahead.js | 2 +- fec/fec/static/js/modules/filters/text-filter.js | 2 +- fec/fec/static/js/modules/search.js | 2 +- fec/fec/static/js/modules/skip-nav.js | 2 +- fec/fec/static/js/modules/tables.js | 4 ++-- fec/fec/static/js/pages/contact-form.js | 2 +- fec/fec/static/js/pages/reporting-dates-tables.js | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fec/fec/static/js/modules/calendar-tooltip.js b/fec/fec/static/js/modules/calendar-tooltip.js index 3b087e968a..99afb82cbe 100644 --- a/fec/fec/static/js/modules/calendar-tooltip.js +++ b/fec/fec/static/js/modules/calendar-tooltip.js @@ -34,6 +34,6 @@ CalendarTooltip.prototype.close = function() { this.$content.remove(); this.exportDropdown.destroy(); this.$container.removeClass('is-active'); - this.$container.focus(); // TODO: jQuery deprecation + this.$container.trigger('focus'); this.events.clear(); }; diff --git a/fec/fec/static/js/modules/calendar.js b/fec/fec/static/js/modules/calendar.js index bdda2ea1cb..07ae30db9c 100644 --- a/fec/fec/static/js/modules/calendar.js +++ b/fec/fec/static/js/modules/calendar.js @@ -350,8 +350,8 @@ Calendar.prototype.managePopoverControl = function(e) { $popover .find('.fc-close') .attr('tabindex', '0') - .focus() // TODO: jQuery deprecation + .trigger('focus') .on('click', function() { - $target.focus(); // TODO: jQuery deprecation + $target.trigger('focus'); }); }; diff --git a/fec/fec/static/js/modules/download.js b/fec/fec/static/js/modules/download.js index c130dd4226..e0b9d80d2a 100644 --- a/fec/fec/static/js/modules/download.js +++ b/fec/fec/static/js/modules/download.js @@ -36,7 +36,7 @@ export function download(url, init, focus) { } if (focus) { - item.$button.focus(); // TODO: jQuery deprecation + item.$button.trigger('focus'); } return item; diff --git a/fec/fec/static/js/modules/dropdowns.js b/fec/fec/static/js/modules/dropdowns.js index 0d1c0762f1..7119dc3ecc 100644 --- a/fec/fec/static/js/modules/dropdowns.js +++ b/fec/fec/static/js/modules/dropdowns.js @@ -85,7 +85,7 @@ Dropdown.prototype.toggle = function(e) { Dropdown.prototype.show = function() { restoreTabindex(this.$panel); this.$panel.attr('aria-hidden', 'false'); - this.$panel.find('input[type="checkbox"]:first').focus(); // TODO: jQuery deprecation (:first and .focus) + this.$panel.find('input[type="checkbox"]').first().trigger('focus'); this.$button.addClass('is-active'); this.isOpen = true; }; @@ -120,7 +120,7 @@ Dropdown.prototype.handleKeyup = function(e) { if (e.keyCode === KEYCODE_ESC) { if (this.isOpen) { this.hide(); - this.$button.focus(); // TODO: jQuery deprecation + this.$button.trigger('focus'); } } }; @@ -221,14 +221,14 @@ Dropdown.prototype.selectItem = function($input) { if (next.length) { $(next[0]) .find('input[type="checkbox"]') - .focus(); // TODO: jQuery deprecation + .trigger('focus'); } else if (prev.length) { $(prev[0]) .find('input[type="checkbox"]') - .focus(); // TODO: jQuery deprecation + .trigger('focus'); } } else { - this.$selected.find('input[type="checkbox"]').focus(); // TODO: jQuery deprecation + this.$selected.find('input[type="checkbox"]').trigger('focus'); } }; diff --git a/fec/fec/static/js/modules/filters/date-filter.js b/fec/fec/static/js/modules/filters/date-filter.js index 6b3d3163ed..14691d429f 100644 --- a/fec/fec/static/js/modules/filters/date-filter.js +++ b/fec/fec/static/js/modules/filters/date-filter.js @@ -334,7 +334,7 @@ DateFilter.prototype.handleGridItemSelect = function(e) { this.$grid.find('li').unbind('mouseenter mouseleave'); // TODO: jQuery deprecation (.unbind()) this.setValue(value); this.$grid.addClass('is-invalid'); - $nextItem.focus(); // TODO: jQuery deprecation + $nextItem.trigger('focus'); } }; diff --git a/fec/fec/static/js/modules/filters/filter-panel.js b/fec/fec/static/js/modules/filters/filter-panel.js index afd68691f3..38d49f7169 100644 --- a/fec/fec/static/js/modules/filters/filter-panel.js +++ b/fec/fec/static/js/modules/filters/filter-panel.js @@ -65,7 +65,7 @@ FilterPanel.prototype.show = function(focus) { this.$body .find('input, select, button:not(.js-filter-close)') .first() - .focus(); // TODO: jQuery deprecation + .trigger('focus'); } }; @@ -76,7 +76,7 @@ FilterPanel.prototype.hide = function() { } this.$body.removeClass('is-open'); this.$content.attr('aria-hidden', true); - this.$focus.focus(); // TODO: jQuery deprecation + this.$focus.trigger('focus'); removeTabindex(this.$form); $('body').removeClass('is-showing-filters'); this.isOpen = false; diff --git a/fec/fec/static/js/modules/filters/filter-typeahead.js b/fec/fec/static/js/modules/filters/filter-typeahead.js index 8827e5fca3..9fc2983fa4 100644 --- a/fec/fec/static/js/modules/filters/filter-typeahead.js +++ b/fec/fec/static/js/modules/filters/filter-typeahead.js @@ -161,7 +161,7 @@ FilterTypeahead.prototype.handleSelected = function(e, datum) { this.$elm.find('label[for="' + id + '"]').addClass('is-loading'); - this.$button.focus().addClass('is-loading'); + this.$button.trigger('focus').addClass('is-loading'); }; FilterTypeahead.prototype.handleAutocomplete = function(e, datum) { diff --git a/fec/fec/static/js/modules/filters/text-filter.js b/fec/fec/static/js/modules/filters/text-filter.js index b424cf8b33..b4724504db 100644 --- a/fec/fec/static/js/modules/filters/text-filter.js +++ b/fec/fec/static/js/modules/filters/text-filter.js @@ -63,7 +63,7 @@ TextFilter.prototype.handleChange = function() { // set the button focus within a timeout // to prevent change event from firing twice setTimeout(function() { - button.focus(); // TODO: jQuery deprecation + button.trigger('focus'); }, 0); if (value.length > 0) { diff --git a/fec/fec/static/js/modules/search.js b/fec/fec/static/js/modules/search.js index 07340a9d0a..0a02b37f4f 100644 --- a/fec/fec/static/js/modules/search.js +++ b/fec/fec/static/js/modules/search.js @@ -32,7 +32,7 @@ export default function Search($el, opts) { $(document.body).on('keyup', function(e) { // Focus search on "/" if (e.keyCode === KEYCODE_SLASH) { - $input.first().focus(); // TODO: jQuery deprecation + $input.first().trigger('focus'); } }); } diff --git a/fec/fec/static/js/modules/skip-nav.js b/fec/fec/static/js/modules/skip-nav.js index f2b315c0f2..7213b055b0 100644 --- a/fec/fec/static/js/modules/skip-nav.js +++ b/fec/fec/static/js/modules/skip-nav.js @@ -28,6 +28,6 @@ Skipnav.prototype.focusOnTarget = function(e) { if (e.keyCode === 13 || e.type === 'click') { this.$target.attr('tabindex', '0'); - this.$target.focus(); // TODO: jQuery deprecation + this.$target.trigger('focus'); } }; diff --git a/fec/fec/static/js/modules/tables.js b/fec/fec/static/js/modules/tables.js index 11a28ce216..ed0038f96c 100644 --- a/fec/fec/static/js/modules/tables.js +++ b/fec/fec/static/js/modules/tables.js @@ -235,7 +235,7 @@ export function modalRenderFactory(template, fetch) { $modal.find('.js-pdf_url').remove(); } // Set focus on the close button - $('.js-hide').focus(); // TODO: jQuery deprecation + $('.js-hide').trigger('focus'); // When under $large-screen // TODO figure way to share these values with CSS. @@ -260,7 +260,7 @@ export function modalRenderFactory(template, fetch) { } function hidePanel(api, $modal) { - $('.row-active .js-panel-button').focus(); // TODO: jQuery deprecation + $('.row-active .js-panel-button').trigger('focus'); $('.js-panel-toggle tr').toggleClass('row-active', false); $('body').toggleClass('panel-active', false); $modal.attr('aria-hidden', 'true'); diff --git a/fec/fec/static/js/pages/contact-form.js b/fec/fec/static/js/pages/contact-form.js index 7020486d99..96e84f681f 100644 --- a/fec/fec/static/js/pages/contact-form.js +++ b/fec/fec/static/js/pages/contact-form.js @@ -43,7 +43,7 @@ ContactForm.prototype.initTypeahead = function() { //focus away to prompt removal of error state, if present. Could only focus into... //...another field, Attempts to focusout, or focus onto body, did not work. $('#id_u_contact_title') - .focus() // TODO: jQuery deprecation + .trigger('focus') .trigger('blur'); }); }; diff --git a/fec/fec/static/js/pages/reporting-dates-tables.js b/fec/fec/static/js/pages/reporting-dates-tables.js index 848d2a3661..eee545dde9 100644 --- a/fec/fec/static/js/pages/reporting-dates-tables.js +++ b/fec/fec/static/js/pages/reporting-dates-tables.js @@ -367,7 +367,7 @@ ReportingDates.prototype.mediaQueryResponse = function(mql) { for (const close of jsmodalClose) { close.addEventListener('click', () => { jsmodal[0].setAttribute('aria-hidden', 'true'); - close.focus(); // TODO: jQuery deprecation + close.trigger('focus'); }); } });