Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kout95 committed Jun 24, 2024
1 parent a624820 commit d2d8103
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/src/mixins/search-ctl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export const SearchaliciousSearchMixin = <T extends Constructor<LitElement>>(
langs: this.langs
.split(PROPERTY_LIST_DIVIDER)
.map((lang) => lang.trim()),
page_size: this.pageSize.toString(),
page_size: this.pageSize?.toString(),
index_id: this.index,
};
// sorting parameters
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/search-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export class SearchaliciousBar extends SuggestionSelectionMixin(
this.search();
};

onClickSearch() {
this.search();
}

override render() {
return html`
<div class="search-bar" part="wrapper">
Expand All @@ -218,15 +222,18 @@ export class SearchaliciousBar extends SuggestionSelectionMixin(
@keydown=${this.onKeyDown}
@focus="${this.onFocus}"
@blur="${this.onBlur}"
.value=${this.value}
.value=${this.query}
placeholder=${this.placeholder}
part="input"
autocomplete="off"
/>
${this.renderSuggestions()}
</div>
<div>
<searchalicious-button :search-name="${this.name}">
<searchalicious-button
:search-name="${this.name}"
@click=${this.onClickSearch}
>
<div class="button-content">
<searchalicious-icon-search></searchalicious-icon-search>
${this.value !== this.lastQuery
Expand All @@ -235,7 +242,7 @@ export class SearchaliciousBar extends SuggestionSelectionMixin(
</div>
</searchalicious-button>
</div>
${this.value
${this.query
? html`<searchalicious-button-transparent @click=${this.onResetInput}
>${msg('Reset')}</searchalicious-button-transparent
>`
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/search-button.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {LitElement, html, css} from 'lit';
import {customElement} from 'lit/decorators.js';
import {SearchActionMixin} from './mixins/search-action';
import {searchBarInputAndButtonStyle} from './css/header';
import {BasicEvents} from './utils/enums';

/**
* An optional search button element that launch the search.
*
* @slot - goes in button contents, default to "Search" string
*/
@customElement('searchalicious-button')
export class SearchaliciousButton extends SearchActionMixin(LitElement) {
export class SearchaliciousButton extends LitElement {
static override styles = [
searchBarInputAndButtonStyle,
css`
Expand All @@ -33,7 +33,7 @@ export class SearchaliciousButton extends SearchActionMixin(LitElement) {
override render() {
return html`
<button
@click=${this._onClick}
@click=${this.dispatchClickEvent}
@keyup=${this._onKeyUp}
part="button"
role="button"
Expand All @@ -45,16 +45,16 @@ export class SearchaliciousButton extends SearchActionMixin(LitElement) {
}

/**
* Launch search by emitting the LAUNCH_SEARCH signal
* Launch search by emitting the click event.
*/
private _onClick() {
this._launchSearch();
dispatchClickEvent() {
this.dispatchEvent(new CustomEvent(BasicEvents.CLICK));
}

private _onKeyUp(event: Event) {
const kbd_event = event as KeyboardEvent;
if (kbd_event.key === 'Enter') {
this._launchSearch();
this.dispatchClickEvent();
}
}
}
Expand Down

0 comments on commit d2d8103

Please sign in to comment.