Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #26153 from Cwiiis/bug1099055-anchor-link-disables…
Browse files Browse the repository at this point in the history
…-rocketbar-collapsing

Bug 1099055 - Fix rocketbar collapse being disabled by anchor links. r=etienne
  • Loading branch information
Cwiiis committed Nov 17, 2014
2 parents 6f6e4b9 + 26b6a05 commit fccfaa8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
24 changes: 17 additions & 7 deletions apps/system/js/app_chrome.js
Expand Up @@ -581,6 +581,14 @@
return;
}

// Check if this is just a location-change to an anchor tag.
var anchorChange = false;
if (this._currentURL && evt.detail) {
anchorChange =
this._currentURL.replace(/#.*/g, '') ===
evt.detail.replace(/#.*/g, '');
}

// We wait a small while because if we get a title/name it's even better
// and we don't want the label to flash
setTimeout(this._updateLocation.bind(this, evt.detail),
Expand Down Expand Up @@ -612,15 +620,17 @@
// We havent got a name for this location
this._gotName = false;

// Make the rocketbar unscrollable until the page resizes to the
// appropriate height.
this.containerElement.classList.remove('scrollable');
if (!anchorChange) {
// Make the rocketbar unscrollable until the page resizes to the
// appropriate height.
this.containerElement.classList.remove('scrollable');

// Expand
if (!this.isMaximized()) {
this.element.classList.add('maximized');
// Expand
if (!this.isMaximized()) {
this.element.classList.add('maximized');
}
this.scrollable.scrollTop = 0;
}
this.scrollable.scrollTop = 0;
};

AppChrome.prototype.handleLoadStart = function ac_handleLoadStart(evt) {
Expand Down
12 changes: 12 additions & 0 deletions apps/system/test/unit/app_chrome_test.js
Expand Up @@ -219,6 +219,18 @@ suite('system/AppChrome', function() {
assert.equal(chrome.backButton.disabled, true);
});

test('location#anchor changed', function() {
var app = new AppWindow(fakeWebSite);
var chrome = new AppChrome(app);
this.sinon.stub(app, 'isBrowser').returns(true);

chrome._currentURL = fakeWebSite.url;
chrome.containerElement.classList.add('scrollable');
chrome.handleEvent({ type: 'mozbrowserlocationchange',
detail: fakeWebSite.url + '#anchor' });
assert.isTrue(chrome.containerElement.classList.contains('scrollable'));
});

test('location changed - without navigation', function() {
var app = new AppWindow(fakeAppWithName);
var chrome = new AppChrome(app);
Expand Down

0 comments on commit fccfaa8

Please sign in to comment.