Skip to content

Commit

Permalink
docs(searchbar): debounce uses ionInput (#2913)
Browse files Browse the repository at this point in the history
Co-authored-by: guillaumesmo <[email protected]>
  • Loading branch information
liamdebeasi and guillaumesmo authored Apr 13, 2023
1 parent b0ac6e8 commit eb79612
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/api/searchbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import Toolbar from '@site/static/usage/v7/toolbar/searchbars/index.md';

## Debounce

A debounce can be set on the searchbar in order to delay triggering the `ionChange` event. This is useful when querying data, as it can be used to wait to make a request instead of requesting the data each time a character is entered in the input.
A debounce can be set on the searchbar in order to delay triggering the `ionInput` event. This is useful when querying data, as it can be used to wait to make a request instead of requesting the data each time a character is entered in the input.

import Debounce from '@site/static/usage/v7/searchbar/debounce/index.md';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```html
<ion-searchbar [debounce]="1000" (ionChange)="handleChange($event)"></ion-searchbar>
<ion-searchbar [debounce]="1000" (ionInput)="handleInput($event)"></ion-searchbar>

<ion-list>
<ion-item *ngFor="let result of results">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class ExampleComponent {
public data = ['Amsterdam', 'Buenos Aires', 'Cairo', 'Geneva', 'Hong Kong', 'Istanbul', 'London', 'Madrid', 'New York', 'Panama City'];
public results = [...this.data];

handleChange(event) {
handleInput(event) {
const query = event.target.value.toLowerCase();
this.results = this.data.filter(d => d.toLowerCase().indexOf(query) > -1);
}
Expand Down
6 changes: 3 additions & 3 deletions static/usage/v7/searchbar/debounce/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
let results = [...data];
filterItems(results);

searchbar.addEventListener('ionChange', handleChange);
searchbar.addEventListener('ionInput', handleInput);

function handleChange(event) {
function handleInput(event) {
const query = event.target.value.toLowerCase();
results = data.filter(d => d.toLowerCase().indexOf(query) > -1);
filterItems(results);
Expand All @@ -61,4 +61,4 @@
}
</script>

</html>
</html>
4 changes: 2 additions & 2 deletions static/usage/v7/searchbar/debounce/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
let results = [...data];
filterItems(results);
searchbar.addEventListener('ionChange', handleChange);
searchbar.addEventListener('ionInput', handleInput);
function handleChange(event) {
function handleInput(event) {
const query = event.target.value.toLowerCase();
results = data.filter(d => d.toLowerCase().indexOf(query) > -1);
filterItems(results);
Expand Down
4 changes: 2 additions & 2 deletions static/usage/v7/searchbar/debounce/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function Example() {
const data = ['Amsterdam', 'Buenos Aires', 'Cairo', 'Geneva', 'Hong Kong', 'Istanbul', 'London', 'Madrid', 'New York', 'Panama City'];
let [results, setResults] = useState([...data]);

const handleChange = (ev: Event) => {
const handleInput = (ev: Event) => {
let query = "";
const target = ev.target as HTMLIonSearchbarElement;
if (target) query = target.value!.toLowerCase();
Expand All @@ -16,7 +16,7 @@ function Example() {

return (
<>
<IonSearchbar debounce={1000} onIonChange={(ev) => handleChange(ev)}></IonSearchbar>
<IonSearchbar debounce={1000} onIonInput={(ev) => handleInput(ev)}></IonSearchbar>

<IonList>
{ results.map(result => (
Expand Down
4 changes: 2 additions & 2 deletions static/usage/v7/searchbar/debounce/vue.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```html
<template>
<ion-searchbar :debounce="1000" @ionChange="handleChange($event)"></ion-searchbar>
<ion-searchbar :debounce="1000" @ionInput="handleInput($event)"></ion-searchbar>

<ion-list>
<ion-item v-for="result in results">
Expand All @@ -22,7 +22,7 @@
return { data, results };
},
methods: {
handleChange(event) {
handleInput(event) {
const query = event.target.value.toLowerCase();
this.results = this.data.filter(d => d.toLowerCase().indexOf(query) > -1);
},
Expand Down

1 comment on commit eb79612

@vercel
Copy link

@vercel vercel bot commented on eb79612 Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ionic-docs – ./

ionic-docs-git-main-ionic1.vercel.app
ionic-docs-ionic1.vercel.app
ionic-docs-gqykycf8t.vercel.app

Please sign in to comment.