From 1a09f15671f91826d33421a12decd2c4b40906af Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Wed, 18 Dec 2013 23:14:10 -0800 Subject: [PATCH] Fix round-off error in Vector's collapsibleTabs.js Values returned by jQuery's .width() are rounded off, whereas offset values computed with .offset() are not. As a result, if the window is sized just right, collapsibleTabs.js will decide it has enough room to expand a tab when it really doesn't. It will then detect the tab overlap caused by squeezing in an additional tab and collapse it. It gets stuck in an infinite loop doing that. We could replace usage of $(el).width() with el.getBoundingClientRect().width and thereby make the width calculations precise, but I noticed that jQuery is nervous enough about the availability of getBoundingClientRect that it includes a check to make sure it is not undefined. Rather than run the risk of a ReferenceError, we can simply require an additional extra pixel of space before we decide to expand anything. Bug: 58682 Change-Id: Ib2096894619b8343735de482ee8bfa20a7cd0f48 --- skins/vector/collapsibleTabs.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skins/vector/collapsibleTabs.js b/skins/vector/collapsibleTabs.js index 83d043e6b9..e33cfc9560 100644 --- a/skins/vector/collapsibleTabs.js +++ b/skins/vector/collapsibleTabs.js @@ -72,8 +72,10 @@ collapsible: 'li.collapsible', shifting: false, expandCondition: function ( eleWidth ) { - // If there's at least eleWidth pixels free space, expand. - return calculateTabDistance() >= eleWidth; + // If there are at least eleWidth + 1 pixels of free space, expand. + // We add 1 because .width() will truncate fractional values + // but .offset() will not. + return calculateTabDistance() >= (eleWidth + 1); }, collapseCondition: function () { // If there's an overlap, collapse. -- 2.20.1