From 532b9c0eaf3ab8154dfc32a5e8a30fe0b9a3b14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 12 Jan 2017 14:26:31 -0800 Subject: [PATCH] collapsibleTabs: Stop the tabs from collapsing back and forth forever Update the 'expandedWidth' after we expand in case someone was brazen enough to change the tab's contents after the page load (gasp). This doesn't prevent a tab from collapsing back and forth once, but at least it won't continue to do that forever. This should reduce the issue from completely awful to mildly annoying. Bug: T71729 Change-Id: I46bd6584c0f2ddebc4aa7d1103cff1715e1510a5 --- collapsibleTabs.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/collapsibleTabs.js b/collapsibleTabs.js index c37d76b..134bc7c 100644 --- a/collapsibleTabs.js +++ b/collapsibleTabs.js @@ -172,8 +172,15 @@ .data( 'collapsibleTabsSettings', data ) .animate( { width: expandedWidth + 'px' }, 'normal', function () { $( this ).attr( 'style', 'display: block;' ); - expContainerSettings.shifting = false; - rAF( $.collapsibleTabs.handleResize ); + rAF( function () { + // Update the 'expandedWidth' in case someone was brazen enough to change the tab's + // contents after the page load *gasp* (T71729). This doesn't prevent a tab from + // collapsing back and forth once, but at least it won't continue to do that forever. + data.expandedWidth = $moving.width(); + $moving.data( 'collapsibleTabsSettings', data ); + expContainerSettings.shifting = false; + $.collapsibleTabs.handleResize(); + } ); } ) ); },