Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
🐛 Position sidebar on correct side on startup
Browse files Browse the repository at this point in the history
Fixes #277
  • Loading branch information
trickypr committed Sep 29, 2023
1 parent 61c1363 commit ab95266
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fix fetching new language packs (bug #287)
- Fix fetching new language packs (bug [#287](https://github.com/pulse-browser/browser/issues/287))
- Sidebar starts up on the correct side of the browser (bug [#277](https://github.com/pulse-browser/browser/issues/277))

## 1.0.0-a.82

Expand Down
32 changes: 18 additions & 14 deletions src/browser/base/content/browser-sidebar-js.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/browser/base/content/browser-sidebar.js b/browser/base/content/browser-sidebar.js
index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf8419d2f6 100644
index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..b607ca233ed7219bff900a98fd1e730968ffe7a4 100644
--- a/browser/base/content/browser-sidebar.js
+++ b/browser/base/content/browser-sidebar.js
@@ -11,6 +11,9 @@ var SidebarUI = {
Expand Down Expand Up @@ -94,7 +94,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
// lastOpenedId is set in show() but unlike currentID it's not cleared out on hide
// and isn't persisted across windows
lastOpenedId: null,
@@ -111,6 +159,48 @@ var SidebarUI = {
@@ -111,6 +159,52 @@ var SidebarUI = {
this._switcherTarget.addEventListener("command", () => {
this.toggleSwitcherPanel();
});
Expand Down Expand Up @@ -139,11 +139,15 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
+ this._box.style.marginLeft = "unset";
+
+ this.loadedSidebars = [];
+
+ // Ensure that the sidebar's position is correct on startup. The position
+ // will be fetched by the lazy preference getter down the bottom
+ this.setPosition();
+
this._switcherTarget.addEventListener("keydown", event => {
this.handleKeydown(event);
});
@@ -120,15 +210,33 @@ var SidebarUI = {
@@ -120,15 +214,33 @@ var SidebarUI = {
Services.obs.addObserver(this, "intl:app-locales-changed");

this._initDeferred.resolve();
Expand Down Expand Up @@ -178,7 +182,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf

if (this._box.hasAttribute("positionend")) {
xulStore.persist(this._box, "positionend");
@@ -160,7 +268,7 @@ var SidebarUI = {
@@ -160,7 +272,7 @@ var SidebarUI = {
/**
* The handler for Services.obs.addObserver.
**/
Expand All @@ -187,7 +191,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
switch (topic) {
case "intl:app-locales-changed": {
if (this.isOpen) {
@@ -171,6 +279,54 @@ var SidebarUI = {
@@ -171,6 +283,54 @@ var SidebarUI = {
this.showInitially(this.lastOpenedId);
break;
}
Expand Down Expand Up @@ -242,7 +246,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
}
}
},
@@ -290,17 +446,31 @@ var SidebarUI = {
@@ -290,17 +450,31 @@ var SidebarUI = {
// First reset all ordinals to match DOM ordering.
let browser = document.getElementById("browser");
[...browser.children].forEach((node, i) => {
Expand Down Expand Up @@ -279,7 +283,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
// Indicate we've switched ordering to the box
this._box.setAttribute("positionend", true);
} else {
@@ -489,6 +659,10 @@ var SidebarUI = {
@@ -489,6 +663,10 @@ var SidebarUI = {
},

_loadSidebarExtension(commandID) {
Expand All @@ -290,23 +294,23 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
let sidebar = this.sidebars.get(commandID);
let { extensionId } = sidebar;
if (extensionId) {
@@ -527,6 +701,7 @@ var SidebarUI = {
@@ -527,6 +705,7 @@ var SidebarUI = {
}

this._fireFocusedEvent();
+ this.loadedSidebars.push(commandID);
return true;
});
},
@@ -550,6 +725,7 @@ var SidebarUI = {
@@ -550,6 +729,7 @@ var SidebarUI = {
}
return this._show(commandID).then(() => {
this._loadSidebarExtension(commandID);
+ this.loadedSidebars.push(commandID);
return true;
});
},
@@ -563,6 +739,38 @@ var SidebarUI = {
@@ -563,6 +743,38 @@ var SidebarUI = {
*/
_show(commandID) {
return new Promise(resolve => {
Expand Down Expand Up @@ -345,7 +349,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
this.selectMenuItem(commandID);

this._box.hidden = this._splitter.hidden = false;
@@ -580,7 +788,13 @@ var SidebarUI = {
@@ -580,7 +792,13 @@ var SidebarUI = {
this.observeTitleChanges(sourceL10nEl);
this.browser.setAttribute("src", url); // kick off async load

Expand All @@ -360,7 +364,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
this.browser.addEventListener(
"load",
event => {
@@ -624,11 +838,14 @@ var SidebarUI = {
@@ -624,11 +842,14 @@ var SidebarUI = {
// create a new content viewer because the old one doesn't get destroyed
// until about:blank has loaded (which does not happen as long as the
// element is hidden).
Expand All @@ -377,7 +381,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf

let selBrowser = gBrowser.selectedBrowser;
selBrowser.focus();
@@ -642,10 +859,27 @@ var SidebarUI = {
@@ -642,10 +863,27 @@ var SidebarUI = {
* none if the argument is an empty string.
*/
selectMenuItem(commandID) {
Expand Down Expand Up @@ -406,7 +410,7 @@ index f5def93f56fc8d02d6ae6834ca8d2df0aead2379..976768180f96c3ae1abec661410d42bf
if (id == commandID) {
menu.setAttribute("checked", "true");
if (triggerbutton) {
@@ -661,6 +895,107 @@ var SidebarUI = {
@@ -661,6 +899,107 @@ var SidebarUI = {
}
}
},
Expand Down

0 comments on commit ab95266

Please sign in to comment.