Skip to content

Commit

Permalink
Clean JS for Search (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
williambelle committed Feb 23, 2024
1 parent 2cf42ee commit 84213b0
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 84213b0

Please sign in to comment.