SupremeTechnopriest / react-idle-timer

User activity timer component
https://idletimer.dev
MIT License
1.15k stars 143 forks source link

🐞 documentation does not include focus in default events. But, should focus be included in default events? #395

Open eliprand opened 3 months ago

eliprand commented 3 months ago

What happened?

We recently upgraded an app that was 3+ years old and upgraded to the latest version of this package. We first started using the default events as the list in the documentation matched what we would expect. However, the actual behavior was different from previous, older versions. Our timeout was not triggering unless we used another app/window. Digging quickly into the code, we quickly found out that focus had been added to the list of default event. At the very least, we should update the docs to match the code (happy to open a PR for that 😉 ). But our bigger question is: should focus really be in the default events? I looked through the issues and I did not find an issue asking for it (very possible I missed it).

The fix for us was pretty easy, we just used DEFAULT_EVENTS (thank you for exporting it...) and simply removed focus from the list that we passed to the useIdleTimeout(). But if the user is on the tab but not doing anything, are they really active?

Reproduction Steps

  1. Visit the Props documentation
  2. Confirm the list of events
  3. Check the code
  4. confirm that the 2 lists are different

Relevant log output

No response

Screenshots or Additional Context

No response

Module Version

5.7.2

What browsers are you seeing the problem on? Select all that apply.

Firefox, Chrome, Safari, Microsoft Edge, Other

What devices are you seeing the problem on?

Desktop, Mobile, Tablet, Wearable, Other

Verification