Skip to content

Commit b60712b

Browse files
kasperg3scheb
authored andcommitted
prevent search box from being cleared on enter
1 parent 714dfa0 commit b60712b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

web_app/static/ts/search.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export class SearchBox {
159159

160160
this.appendNoResult();
161161
input.addEventListener('input', delay(this.onInput.bind(this), 800))
162+
input.addEventListener('keydown', this.onKeyDown.bind(this))
162163
if (input.value.length > 0) {
163164
this.search(input.value)
164165
}
@@ -170,6 +171,13 @@ export class SearchBox {
170171
}
171172
}
172173

174+
private onKeyDown(evt: KeyboardEvent): void {
175+
if (evt.key === 'Enter' && evt.target instanceof HTMLInputElement) {
176+
evt.preventDefault()
177+
this.search(evt.target.value)
178+
}
179+
}
180+
173181
private search(searchTerm: string): void {
174182
const splitter = /[\s_\-.,;:]+/g
175183
this.rawSearchTerm = searchTerm

0 commit comments

Comments
 (0)