Skip to content

Commit

Permalink
fix: table filters starting user search in topbar
Browse files Browse the repository at this point in the history
Due to the use of `search-input` also taking place in bootstrap-table, those fields suddenly became search fields for topbar as well. Added a new unique class. Not id because then it'd require two which are now allowed according to HTML standard
  • Loading branch information
blt950 committed Sep 30, 2023
1 parent 8f3ccc8 commit 95ce203
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions resources/views/layouts/topbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="search-icon bg-light input-group-prepend">
<i class="fas fa-search fa-sm"></i>
</div>
<input class="search-input form-control bg-light border-0 small" type="text" name="search" placeholder="Search for user">
<input class="user-search search-input form-control bg-light border-0 small" type="text" name="search" placeholder="Search for user">
</div>

<div class="search-spinner spinner-border spinner-border-sm" role="status"></div>
Expand Down Expand Up @@ -50,7 +50,7 @@
<div class="search-icon bg-light input-group-prepend">
<i class="fas fa-search fa-sm"></i>
</div>
<input class="search-input form-control bg-light border-0 small" type="text" name="search" placeholder="Search for user">
<input class="user-search search-input form-control bg-light border-0 small" type="text" name="search" placeholder="Search for user">
</div>

<div class="search-spinner spinner-border spinner-border-sm" role="status"></div>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/scripts/global.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function showResults(boolean, html = null){
// Start search when typing in search bar with a 200ms delay
var timer = null
document.querySelectorAll('.search-input').forEach((input) => {
document.querySelectorAll('.user-search').forEach((input) => {
input.addEventListener('keyup', function(){
showSpinner(true)
clearTimeout(timer);
Expand All @@ -95,7 +95,7 @@ function showResults(boolean, html = null){
userSearchFormDesktop.addEventListener('submit', function(e){
e.preventDefault();
var query = parseInt(document.querySelector('.search-input').value);
var query = parseInt(document.querySelector('.user-search').value);
if(Number.isInteger(query)){
location.assign("{{ route('user.show', '') }}/" + query);
}
Expand All @@ -110,7 +110,7 @@ function showResults(boolean, html = null){
e.preventDefault()
var query = null
document.querySelectorAll('.search-input').forEach((el) => {
document.querySelectorAll('.user-search').forEach((el) => {
if(el.value != '') query = el.value
});
Expand Down

0 comments on commit 95ce203

Please sign in to comment.