Skip to content

Commit

Permalink
Clean JS for Search
Browse files Browse the repository at this point in the history
- Fix eslint warnings and errors
- Fix deprecated jQuery API
  • Loading branch information
williambelle committed Dec 1, 2023
1 parent f0b55e3 commit 5cec732
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions assets/components/molecules/search/search-mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@

export default () => {

$('#search-mobile-toggle').click(function(event){
$('#search-mobile-toggle').on('click', () => {

var searchContainer = $('.search-mobile');
var searchField = searchContainer.find('.form-control');
const searchContainer = $('.search-mobile');
const searchField = searchContainer.find('.form-control');

searchContainer.toggleClass('show');
$('body').toggleClass('search-open');

if ( searchContainer.hasClass('show') ) {
searchField.focus();
if (searchContainer.hasClass('show')) {
searchField.trigger('focus');
}

});

$('#search-mobile-close').click(function(event){
$('#search-mobile-close').on('click', () => {

var searchContainer = $('.search-mobile');
var searchField = searchContainer.find('.form-control');
const searchContainer = $('.search-mobile');

searchContainer.removeClass('show');
$('body').removeClass('search-open');
Expand Down
2 changes: 1 addition & 1 deletion assets/components/molecules/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

export default () => {
$('.search').on('shown.bs.dropdown', () => {
$('.search input[type="text"]').focus();
$('.search input[type="text"]').trigger('focus');
});
};

0 comments on commit 5cec732

Please sign in to comment.