Unclear which events trigger "activity" for idleTimer #397
Replies: 2 comments 4 replies
-
The const idletimer = useIdleTimer({
events: [
'mousemove',
'keydown',
'wheel',
'DOMMouseScroll',
'mousewheel',
'mousedown',
'touchstart',
'touchmove'
]
}) |
Beta Was this translation helpful? Give feedback.
-
Thanks again @SupremeTechnopriest - one follow-up question: Your suggestion above for restricting the timer reset events to the browser tab/window that's hosting the timer was to use this set:
The default array of events is:
So in your suggestion, in addition to removing When I look at what those events mean, I see:
It's hard to tell if this would be fired only in the context of the attached tab's DOM or not. Do you know what this event does in the context of Thanks |
Beta Was this translation helpful? Give feedback.
-
We have implemented
idleTimer
in a production application, and our testing is showing inconsistent behavior with when the timer is reset, or when it expires/prompts.In some cases, we see behavior that seems to suggest that the activity switching from the application tab to a different tab, and then back to the application tab - without any actual activity in the browser DOM (mouse events, keyboard events, etc) - are causing the timer to reset. So if the timer is 15 minutes, and we switch tabs from the application to toher tabs over the course of 5 minutes, then the timer expires in 20 minutes, not 15 minutes.
In other cases, specifically on a Mac with Safari v17.3, we're seeing that staying in the application tab with no activity whatsoever, the timer will never expire and will never prompt. So with a timer of 15 minutes, even after 15 minutes we see no prompt.
I see in the docs for the
events
prop it says "DOM events to watch for activity on". So our question is:I.e., is the scope of events that will cause timer reset the application tab/window, the entire browser window, or all computer input device events?
And how does this explain the second case above?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions