fix(search): Stop clear enter propagation

Signed-off-by: Carlos Esteban Lopez <lcarlosesteb@vmware.com>
This commit is contained in:
Carlos Esteban Lopez
2023-04-17 13:07:06 -05:00
committed by Carlos Lopez
parent d1ffbb5cce
commit 46310ee03f
2 changed files with 15 additions and 3 deletions
@@ -133,7 +133,17 @@ export const SearchBarBase: ForwardRefExoticComponent<SearchBarBaseProps> =
const endAdornment = (
<InputAdornment position="end">
<Button aria-label="Clear" size="small" onClick={handleClear}>
<Button
aria-label="Clear"
size="small"
onClick={handleClear}
onKeyDown={event => {
if (event.key === 'Enter') {
// write your functionality here
event.stopPropagation();
}
}}
>
Clear
</Button>
</InputAdornment>
@@ -103,7 +103,7 @@ const useStyles = makeStyles(theme => ({
viewResultsLink: { verticalAlign: '0.5em' },
}));
export const Modal = () => {
export const Modal = ({ toggleModal }: SearchModalChildrenProps) => {
const classes = useStyles();
const navigate = useNavigate();
const { transitions } = useTheme();
@@ -204,7 +204,9 @@ export const SearchModal = (props: SearchModalProps) => {
>
{open && (
<SearchContextProvider inheritParentContextIfAvailable>
{(children && children({ toggleModal })) ?? <Modal />}
{(children && children({ toggleModal })) ?? (
<Modal toggleModal={toggleModal} />
)}
</SearchContextProvider>
)}
</Dialog>