Skip to content

Commit 621b442

Browse files
committed
chore: added search functionality on enter and space key press
1 parent d0fc1a7 commit 621b442

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

elements/pf-search-input/pf-search-input.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export class PfSearchInput extends LitElement {
191191
accessible-label="search"
192192
id="toggle-input"
193193
?disabled="${disabled}"
194+
@keydown=${this.#onSearchInput}
194195
placeholder="${placeholder || this.#buttonLabel}">
195196
</pf-text-input>
196197
<pf-button
@@ -312,6 +313,14 @@ export class PfSearchInput extends LitElement {
312313
}
313314
return false;
314315
}
316+
317+
#onSearchInput(event: KeyboardEvent) {
318+
if (event.key === 'Enter' || event.key === ' ') {
319+
this.value = this._toggleInput?.value;
320+
this.#internals.setFormValue(this.value ?? '');
321+
this.dispatchEvent(new PfSearchChangeEvent());
322+
}
323+
}
315324
}
316325

317326
declare global {

0 commit comments

Comments
 (0)