Skip to content
Snippets Groups Projects
Commit 0da14c01 authored by druid's avatar druid
Browse files

behaviour

parent 5dd697dd
No related branches found
No related tags found
No related merge requests found
...@@ -54,16 +54,7 @@ export class SiteSearch { ...@@ -54,16 +54,7 @@ export class SiteSearch {
this.isSearchPanelOpen = false; this.isSearchPanelOpen = false;
} }
// Close the search panel if user clicks anywhere outside the Search component. handleSearchPanelToggle(event) {
@Listen('click', {target: 'window'})
handleWindowClick(event) {
if (event.target.tagName.toLowerCase() !== 'hy-site-search') {
this.isSearchPanelOpen = false;
}
event.stopPropagation();
}
handleSearchPanelToggle() {
this.isSearchPanelOpen = !this.isSearchPanelOpen; this.isSearchPanelOpen = !this.isSearchPanelOpen;
if (this.isSearchPanelOpen) { if (this.isSearchPanelOpen) {
...@@ -79,7 +70,7 @@ export class SiteSearch { ...@@ -79,7 +70,7 @@ export class SiteSearch {
const searchPanel = this.el.shadowRoot.querySelectorAll(`.site-search__panel`)[0] as HTMLElement; const searchPanel = this.el.shadowRoot.querySelectorAll(`.site-search__panel`)[0] as HTMLElement;
searchPanel.style.top = headerHeight; searchPanel.style.top = headerHeight;
} }
//event.stopPropagation(); event.stopPropagation();
} }
handleSearchPanelClose() { handleSearchPanelClose() {
...@@ -101,7 +92,7 @@ export class SiteSearch { ...@@ -101,7 +92,7 @@ export class SiteSearch {
'is-open--menu': this.isAlternative, 'is-open--menu': this.isAlternative,
'is-open': this.isSearchPanelOpen, 'is-open': this.isSearchPanelOpen,
}} }}
onClick={() => this.handleSearchPanelToggle()} onClick={(e) => this.handleSearchPanelToggle(e)}
> >
{this.showLabel ? <span class={'button--search__label'}>{this._labels['label']}</span> : ''} {this.showLabel ? <span class={'button--search__label'}>{this._labels['label']}</span> : ''}
<hy-icon icon={'hy-icon-search'} size={this.size} fill={this.color} /> <hy-icon icon={'hy-icon-search'} size={this.size} fill={this.color} />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment