From d6e95adf8ce138b456d96df9306803992857e828 Mon Sep 17 00:00:00 2001 From: "vinu.ganesan" Date: Wed, 3 Jul 2024 12:25:19 +0530 Subject: [PATCH] USearchBox onChange prop added --- package.json | 2 +- src/components/USearchBox/USearchBox.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1eafaf171..3e51e5e50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@unicef/material-ui", - "version": "0.12.5", + "version": "0.12.6", "description": "UNICEF theme and components of material-ui for react", "main": "index.js", "files": [ diff --git a/src/components/USearchBox/USearchBox.js b/src/components/USearchBox/USearchBox.js index fbfbd4e66..07690e83c 100644 --- a/src/components/USearchBox/USearchBox.js +++ b/src/components/USearchBox/USearchBox.js @@ -42,6 +42,7 @@ export default function USearchBox({ className, showSeparator, iconLabel, + onChange, ...rest }) { const [searchValue, setSearch] = useState(value) @@ -52,7 +53,9 @@ export default function USearchBox({ }, [value]) const handleChange = event => { - setSearch(event.target.value) + const value = event.target.value + setSearch(value) + onChange && onChange(value) } const applySearch = val => { @@ -136,6 +139,8 @@ USearchBox.propTypes = { showSeparator: PropTypes.bool, /** Label next to the search icon */ iconLabel: PropTypes.string, + /** Callback function when change the search text */ + onchange: PropTypes.func, } USearchBox.defaultProps = {