Skip to content

Commit

Permalink
Merge pull request #435 from alan-rudzinski/feature/clearEvent
Browse files Browse the repository at this point in the history
Add Clear event #411
  • Loading branch information
TarekRaafat authored Oct 16, 2024
2 parents 60329e5 + 7e10ff3 commit 3d32bb1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -706,3 +706,18 @@ document.querySelector("#autoComplete").addEventListener("close", function (even
console.log(event.detail);
});
```

***

### clear

> Fires after "resultsList" is cleared
##### Example:

```js
document.querySelector("#autoComplete").addEventListener("clear", function (event) {
// "event.detail" carries the autoComplete.js "feedback" object
console.log(event.detail);
});
```
5 changes: 5 additions & 0 deletions src/controllers/listController.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ const navigate = (event, ctx) => {
// Clear "input" value
ctx.input.value = "";

/**
* @emit {clear} event on input clear
**/
eventEmitter('clear', ctx);

close(ctx);
break;
}
Expand Down

0 comments on commit 3d32bb1

Please sign in to comment.