fix: search popup not closing
This commit is contained in:
1 parent
289960ea40
commit
1b5f48b1b2
2 files changed
+40
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<!--start header-->
|
||||
<header class="top-header">
|
||||
<nav class="navbar navbar-expand align-items-center gap-4">
|
||||
<nav class="navbar navbar-expand align-items-center gap-4" (click)="closeSearchPopup()">
|
||||
<div class="btn-toggle" (click)="toggleSidebar()">
|
||||
<a href="javascript:;"><i class="material-icons-outlined">menu</i></a>
|
||||
</div>
|
||||
@@ -578,4 +578,27 @@
|
||||
|
||||
</nav>
|
||||
</header>
|
||||
<script>
|
||||
new PerfectScrollbar(".search-content")
|
||||
$(".search-control").click(function(){
|
||||
$(".search-popup").addClass("d-block");
|
||||
$(".search-close").addClass("d-block");
|
||||
});
|
||||
|
||||
|
||||
$(".search-close").click(function(){
|
||||
$(".search-popup").removeClass("d-block");
|
||||
$(".search-close").removeClass("d-block");
|
||||
});
|
||||
|
||||
|
||||
$(".mobile-search-btn").click(function(){
|
||||
$(".search-popup").addClass("d-block");
|
||||
});
|
||||
|
||||
|
||||
$(".mobile-search-close").click(function(){
|
||||
$(".search-popup").removeClass("d-block");
|
||||
});
|
||||
</script>
|
||||
<!--end top header-->
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, ElementRef, HostListener } from '@angular/core';
|
||||
import { ToggleService } from '../../services/toggle.service';
|
||||
|
||||
@Component({
|
||||
@@ -9,7 +9,7 @@ import { ToggleService } from '../../services/toggle.service';
|
||||
export class NavbarComponent {
|
||||
showSearchPopup: boolean = false;
|
||||
|
||||
constructor(private toggleService: ToggleService) {}
|
||||
constructor(private toggleService: ToggleService, private eRef: ElementRef) {}
|
||||
|
||||
toggleSidebar() {
|
||||
this.toggleService.toggleSidebar();
|
||||
@@ -18,4 +18,18 @@ export class NavbarComponent {
|
||||
toggleSearchPopup() {
|
||||
this.showSearchPopup = !this.showSearchPopup;
|
||||
}
|
||||
|
||||
closeSearchPopup() {
|
||||
// if (this.showSearchPopup) this.showSearchPopup = !this.showSearchPopup;
|
||||
}
|
||||
|
||||
@HostListener('document:click', ['$event'])
|
||||
clickout(event: { target: any }) {
|
||||
if (
|
||||
!this.eRef.nativeElement.contains(event.target) &&
|
||||
this.showSearchPopup
|
||||
) {
|
||||
this.showSearchPopup = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user