Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Activity closes the Warning window #26

Open
blerimj opened this issue Sep 1, 2015 · 11 comments
Open

User Activity closes the Warning window #26

blerimj opened this issue Sep 1, 2015 · 11 comments

Comments

@blerimj
Copy link

blerimj commented Sep 1, 2015

Hello there,
I use the session timeout library with these settings:
$.sessionTimeout({
keepAlive: false,
logoutUrl: '/logout',
redirUrl: '/logout',
warnAfter: 300000,
redirAfter: 330000,
countdownMessage: 'Redirecting in {timer} seconds.'
});
The problem I experience is that after the warning is shown to the user, the modal is closed after mouse move. I expect the modal to stay open until the timer expires or the user click on one of two buttons: Stay Conntected or Logout.

Thanks, Blerim

@clemsontiger
Copy link

was going to look into maybe using this but if it reads activity on a mouse move, no way. a mouse could easily be bumped, etc. i would not assume that means the user is "active" for determining timing out or not. I agree with blerimj about the modal staying until the user make a decision or the timer expires.

@Q1WP
Copy link

Q1WP commented Sep 5, 2015

I am not sure how to do this the proper "GitHub" way, but on the bootstrap-session-timeout.js file, I wrapped the contents of the function starting on line #98

$(document).on('keyup mouseup mousemove touchend touchmove', function(e) { 

with

if (!$('#session-timeout-dialog').hasClass('in')) {

and remove the modal specific lines (originally 109-119 which would now prevent the user activity from resetting the session timer and closing the dialog.

So it becomes...

$(document).on('keyup mouseup mousemove touchend touchmove', function(e) {
        if (!$('#session-timeout-dialog').hasClass('in')) {
          if (e.type === 'mousemove') {
            // Solves mousemove even when mouse not moving issue on Chrome:
            // https://code.google.com/p/chromium/issues/detail?id=241476
            if (e.clientX === mousePosition[0] && e.clientY === mousePosition[1]) {
              return;
            }
            mousePosition[0] = e.clientX;
            mousePosition[1] = e.clientY;
          }
          startSessionTimer();
        }
      });

Just my two cents.

@jt2k
Copy link

jt2k commented Dec 29, 2015

User activity closing the modal was intentionally added in 1.0.3 with commit 4b5b865.

However, the readme file says:

On any user action (mouse, keyboard or touch) the timeout timer is reset. Of course, you will still need to close the dialog.

Is there a reason why this behavior was changed? It is a strange user experience to see the modal pop up and then immediately disappear upon moving the mouse without being able to click on either button option.

@powpow12
Copy link

powpow12 commented Jan 7, 2016

Here is the diff from 4b5b865 --> master

This is what was removed

 if( $('#session-timeout-dialog').length > 0 &&
       $('#session-timeout-dialog').data('bs.modal').isShown )
   {
       $('#session-timeout-dialog').remove();

this is what was added

    if ($('#session-timeout-dialog').length > 0 &&
       $('#session-timeout-dialog').data('bs.modal') &&
       $('#session-timeout-dialog').data('bs.modal').isShown) {
       // http://stackoverflow.com/questions/11519660/twitter-bootstrap-modal-backdrop
       $('#session-timeout-dialog').modal('hide');
       $('body').removeClass('modal-open');
       $('div.modal-backdrop').remove();

   }

I'll add a new parameter actionHidesModal which will default to false. This flag will be used as a condition to determine which logic to use. When false, the modal will not be hidden on mouse movement.

@powpow12
Copy link

powpow12 commented Jan 7, 2016

please take a look at https://github.com/powpow12/bootstrap-session-timeout/tree/features/action_hides_modal. A few things to clarify,

I'll add a new parameter actionHidesModal

This is currently anyActionHidesModal, but I think it will make more sense as hideModalonAction

which will default to false

I don't know if makes more sense to have the current logic be the default or the new "better" logic. I could go either way on it

When false, the modal will not be hidden on mouse movement.

The only way you can close the modal is via the close, logout, or keep me logged in buttons

@jkenny6
Copy link

jkenny6 commented Mar 24, 2017

The flag is actually called ignoreUserActivity. So set that to false and the mouse moves don't close the dialog.

Very nice little utility.

@neubreed
Copy link

With ignoreUserActivity the session dialogue pops up regardless of the user's activity which is a bit annoying for them .. It's a better UX to pop up with no user activity at the timeout.

The way it's working currently makes the dialogue buttons redundant because the user can't click them in time. Or does ignoreUserActivity still reset the timeout?

@sajalmathur
Copy link

@blerimj use ignoreUserActivity:true property

@patrickryan79
Copy link

I agree with several comments. It seems counterintuitive to hide the modal once it appears on activity. Using the prop ignoreUserActivity eliminates this problem but also removes the keep-alive functionality that makes the plugin fantastic.

No complaints as this is a fantastic utility. I did something similar to @powpow12 example.

@hansheung
Copy link

hansheung commented May 3, 2019

How to reset the timer or keep alive if mouse and keyboard is in-use. And when idle and pop up, mouse move will not hide the modal? I tried the following but not working. Please help.

$.sessionTimeout({
    keepAliveUrl: '../Home/Logout',
    keepalive: **false, or 'onStayConnectedClick',**
    logoutUrl: '../Home/Logout',
    redirUrl: '../Home/Logout',
    warnAfter: 2000,
    redirAfter: 4000,
    countdownMessage: 'Redirecting in {timer} seconds.',
    countdownBar: true,
    ignoreUserActivity: true
});

@lcsqlpete
Copy link

I have HideModalOnAction set to false but the modal still closes as soon as I move the mouse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests