AutoComplete: setTimeout() in hide-function sometimes causes NULL-Pointer Exception #2881
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
Describe the bug
I am using the PrimeVue AutoComplete component to realize a search bar that displays suggestions. When the user hits enter (and does not click on any of the suggestion) he gets redirected to a search results page. This sometimes causes a NULL-Pointer exception:
Upon closer inspection, it turns out that the
hide()
function is called whenever the user hits enter inside the AutoComplete. This function then does not hide the AutoComplete results directly, but calls asetTimeout()
todo so (see source excerpt below)This results in the
_hide()
occasionally getting called when the AutoComplete component no longer exists resulting in a NULL-Pointer-Exception (at least that is my working theory). Proposed solution: Remove the setTimeout() or introduce proper null checks into the_hide()
function.Reproducer
https://codesandbox.io/s/jovial-poitras-n5kouo
PrimeVue version
3.16.1
Vue version
3.x
Language
ALL
Build / Runtime
Vue CLI App
Browser(s)
Tested in Chrome 104.0 but other browsers are likely effected as well
Steps to reproduce the behavior
Since the issue is browser-timeout based, reproducing it can be tricky.
To reliably reproduce the issue:
setTimeout()
call from0
to100
(don't forget to save the changes)The manually increased
setTimeout()
time is only required for reliable replication, it also sometimes happens without the change (at least in my real-world app with a lot more components and work for the browser)Expected behavior
I expect no error to occur
The text was updated successfully, but these errors were encountered: