react-idle-timer: Idle timer not starting with crossTab without a usr mouse/keyboard event
The recent crossTab feature is greatly appreciated, but I’ve found that if there is no mouse/keyboard event by the user after creating the react-idle-timer component that it appears that the idle timer never gets started (until a mouse/keyboard event is performed by the user).
I’ve tried to call start(), reset() and pause()/resume() in React’s componentDidUpdate() method. But, without a user initiated event the page will never timeout.
For example steps:
- Login to my web app (and afterwards the user do not cause any mouse/keyboard events).
- Internally the react-idle-timer component is created.
- The page current web app will never timeout, until a mouse/keyboard event occurs (e.g., the mouse was moved or key pressed).
- After moving the mouse (or another mouse/keyboard event) and then idle for the set amount of time, I see that the onActive() event occurs and the web app is timed out as expected.
If crossTab is not used, no mouse/keyboard event is initially needed by the user for the the react-idle-timer to start and timeout as expected.
Here is how I configured IdleTimer :
<IdleTimer
ref={ref => { this.idleTimer = ref }}
crossTab={{
type: 'localStorage',
emitOnAllTabs: true
}}
timeout={this.state.timeoutValue}
onAction={this.onAction}
onActive={this.onActive}
onIdle={this.onIdle}>
</IdleTimer>
I’ve tried emitOnAllTabs: false as well.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 40 (20 by maintainers)
Sorry work is a little busy at the moment. Its going to be a little bit before I can do another pass on Idle Timer. I will reopen this so its tracked.
hi @SupremeTechnopriest first of all thanks for the awesome module. However I’m facing the issue in my project and I guess it’s same what @ahayden-lg had faced above. I’m using it with next Js below is my config and methods
now issue is when ever I’m trying to exclude the event
mousemoveonIdledoes not trigger not only onIdle but also theonPresenceChangeas well unless done any action like clicking through the mouse (since move event is off) or any keypress.The behavior is quite weird let me know If I’m doing anything wrong, I did a lot of head scratching but unable to resolve the issue.
Sure no problem. Im just having a hard time understanding why that would be. All calling
resetwould do is recreate the timer and fire anonActiveevent. Thestartmethod is called automatically as long asstartOnMountis notfalseandstartManuallyis not true.Inside the
IdleTimer.componentDidUpdateI check foridleand an updatedtimeoutprop and callreset()automatically:So I’m landing on something inside your
onActivehandler is doing something to the IdleTimer component instance. But all you have is a log there? Im kind of at a loss. Maybe if someone else hits this issue we can get some more information to figure out why this happens.Im going to close this issue for now and release 4.6.1 to the latest tag. It has some good bug fixes and improvements that should get out asap.
Thanks for the detailed breakdown! I will get into it tomorrow.
I create a sample app with
create-react-appand also installed the next release withyarn upgrade react-idle-timer@next.App.js
IdleTimeout.js
Without crossTab everything runs as expected on a single tab, such as…
yarn start)With crossTab after waiting the timeout of 7 secs, I’m not seeing onIdle trigger prior to the mouse entering the page (same for 4.60 and 4.6.1-rc.5). After entering the page I see onAction and onActive trigger but not onIdle trigger (which I did see trigger with 4.60).
yarn start)