[Rt-commit] rt branch 5.0/fix-submenu-drift created. rt-5.0.2-259-g61928173c3
BPS Git Server
git at git.bestpractical.com
Thu Jun 9 13:03:44 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/fix-submenu-drift has been created
at 61928173c3737ce14051ac04e12524d46b2a30c7 (commit)
- Log -----------------------------------------------------------------
commit 61928173c3737ce14051ac04e12524d46b2a30c7
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jun 9 05:21:26 2022 +0800
Fix the flash issue when clicking submenus
On some browsers like Chrome, the submenu could be flashed out if we set
display to "none" right before re-rendering it, when it was shown
already.
This commit fixes the issue by setting it back to its original display,
which is more robust from all aspects.
diff --git a/share/static/js/jquery.supposition.js b/share/static/js/jquery.supposition.js
index f22d1da5bb..1ff89c3993 100644
--- a/share/static/js/jquery.supposition.js
+++ b/share/static/js/jquery.supposition.js
@@ -33,6 +33,7 @@
onBeforeShow = function(){
this.each(function(){
var $u = $(this);
+ var old_display = $u.css('display');
$u.css('display','block');
var tolerance = 0.1; // make following conditions more tolerant to get rid of the precision issue.
@@ -53,7 +54,7 @@
if (expandUp) {
$u.css('margin-top',baseline - (menuHeight + offsetTop));
}
- $u.css('display','none');
+ $u.css('display', old_display);
});
};
commit e7daf5c2314d0ef8e97a3df0daecb1f74e98c25c
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jun 9 04:16:15 2022 +0800
Fix the menu drift issue when clicking repositioned submenus
jquery.supposition.js is to tweak submenu positions if they overflow
screen in original positions. E.g. to lift the Scrips submenu from:
Admin
Users
Groups
Queues
...
Global Scrips
Conditions
Actions
Templates
...
Topics
to
Admin
Users Scrips
Groups Conditions
Queues Actions
... Templates
Global ...
Topics
Previously if you clicked one link in a repositioned submenu, the
submenu would be repositioned(again) back to the orignal position, which
we call a "drift" here. It is acutally a tricky precision issue, e.g.
var expandUp = (offsetTop + menuHeight > baseline);
if (expandUp) {
$u.css('margin-top', baseline - (menuHeight + offsetTop));
}
Even if "margin-top" is set correctly, "expandUp" could still be true
next time as "offsetTop + menuHeight - baseline" could be non-zero like
0.003, which would then set "margin-top" back to nearly 0, i.e. its
original position. This commit fixes this issue by allowing a bit
tolerance.
diff --git a/share/static/js/jquery.supposition.js b/share/static/js/jquery.supposition.js
index a2e057102a..f22d1da5bb 100644
--- a/share/static/js/jquery.supposition.js
+++ b/share/static/js/jquery.supposition.js
@@ -34,11 +34,14 @@
this.each(function(){
var $u = $(this);
$u.css('display','block');
+ var tolerance = 0.1; // make following conditions more tolerant to get rid of the precision issue.
+
var menuWidth = $u.width(),
parentWidth = $u.parents('ul').width(),
totalRight = $w.width() + _offset('x'),
menuRight = $u.offset().left + menuWidth;
- if (menuRight > totalRight) {
+
+ if (menuRight > totalRight + tolerance) {
$u.css('margin-left', ($u.parents('ul').length === 1 ? totalRight - menuRight : -(menuWidth + parentWidth)) + 'px');
}
@@ -46,7 +49,7 @@
offsetTop = $u.offset().top,
menuHeight = $u.height(),
baseline = windowHeight + _offset('y');
- var expandUp = (offsetTop + menuHeight > baseline);
+ var expandUp = (offsetTop + menuHeight > baseline + tolerance);
if (expandUp) {
$u.css('margin-top',baseline - (menuHeight + offsetTop));
}
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list