• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Active User Upgrade Date Calendar Shows After Edit Cancel

Snog

Well-known member
#1
If you're on the Active User Upgrade page, click 'Edit' for the first user in the list then click 'Cancel'. The date selection calendar will show on the page. You can click anywhere on the page to clear the calendar from view.

activecal.jpg
 

Chris D

XenForo developer
Staff member
#2
I think this is a caching issue.

I'm not sure exactly what version, possibly 1.4 Beta 1 or one of the early betas, some code was added to the dateinput JS to handle this particular case (form resets focusing the date input field).

I was surprised a moment ago to see I could reproduce this on my own site; but after a few hard refreshes I couldn't reproduce it again. Hence my belief it's a browser cache issue.
 

Chris D

XenForo developer
Staff member
#3
Actually, randomly, it seems I can reproduce it; despite this code which should handle it:
Code:
// this is needed to handle input[type=reset] buttons that end up focusing the field
$date.closest('form').on('reset', function() {
    setTimeout(function() {
        $date.data('dateinput').hide();
    }, 0);
});
 

Chris D

XenForo developer
Staff member
#4
I was intrigued because I had to reproduce some of this code for my own add-on which displays month / year selectors in the calendar. I observe the same behaviour.

It's basically a race condition where the calendar seems to be hidden before it is shown again.

There might be a better fix, but setting the timeout to 5 seems to do the trick.
 

Mike

XenForo developer
Staff member
#5
I've done 2 levels with this -- one at 10 and one at 100. Strictly speaking, it seems like the reset event fires before it actually does the reset, so I'm not sure that 10 would automatically cover it in all scenarios (all machines, phones, etc). So the 10ms delay should catch it, but there isn't really a harm to closing it again at 100ms (unless you've managed to re-open the input in a tenth of a second ;)).