Autocomplete onSubmit preventDefault() works but produces error

I’m using Autocomplete in NextJS and I’m trying to display a ‘No results’ message and prevent the modal from closing if the user hits the Enter key.

Here’s my code: useEffect(() => { if (!containerRef.current) { return undefined; - Pastebin.com

I’ve added event.preventDefault() in the onSubmit handler, but it produces the following error even though it does actually work:

Uncaught TypeError: event.preventDefault is not a function

Is there any way to apply the preventDefault() call without producing this error?

Thanks!