Skip to content

Commit 616475b

Browse files
committed
chore: search change event updated
1 parent 1d96eec commit 616475b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

elements/pf-search-input/demo/pf-search-input-autocomplete.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="container">
22
<h1>Search with autocomplete</h1>
3-
<pf-search-input placeholder="Search">
3+
<pf-search-input id="search-input" placeholder="Search">
44
<pf-option value="Alabama"> Alabama </pf-option>
55
<pf-option value="New Jersey"> New Jersey </pf-option>
66
<pf-option value="New York"> New York </pf-option>
@@ -26,6 +26,15 @@ <h1>Search with autocomplete</h1>
2626

2727
<script type="module">
2828
import '@patternfly/elements/pf-search-input/pf-search-input.js';
29+
30+
const searchInput = document.getElementById('search-input');
31+
32+
searchInput.addEventListener('change', (event) => {
33+
/* eslint-disable no-console */
34+
console.log('Selected:', event.target.value);
35+
/* eslint-disable no-console */
36+
});
37+
</script
2938
</script>
3039

3140
<style>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import styles from './pf-search-input.css';
2020
import { PfOption } from '../pf-select/pf-option.js';
2121
import { bound } from '@patternfly/pfe-core/decorators.js';
2222

23-
export class PfSelectChangeEvent extends Event {
23+
export class PfSearchChangeEvent extends Event {
2424
constructor() {
2525
super('change', { bubbles: true });
2626
}
@@ -246,7 +246,7 @@ export class PfSearchInput extends LitElement {
246246
@observes('value')
247247
private valueChanged() {
248248
this.#internals.setFormValue(this.value ?? '');
249-
this.dispatchEvent(new PfSelectChangeEvent());
249+
this.dispatchEvent(new PfSearchChangeEvent());
250250
}
251251

252252

0 commit comments

Comments
 (0)