UX: Docking/undocking sidebar toggles sidebar hamburger dropdown (#17636)
Before this change, undocking the sidebar would just hide the sidebar from the screen which led people to complain that they "lost" their sidebar and had to "find" it. With this change, we automatically display the sidebar hamburger dropdown when you undock the sidebar. Like wise when the sidebar is docked, the sidebar hamburger dropdown is automatically collapsed.
This commit is contained in:
parent
228c14479b
commit
07424b9bb6
|
@ -236,17 +236,6 @@ const SiteHeaderComponent = MountWidget.extend(
|
||||||
this.appEvents.on("user-menu:rendered", this, "_animateMenu");
|
this.appEvents.on("user-menu:rendered", this, "_animateMenu");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
this.currentUser?.experimental_sidebar_enabled &&
|
|
||||||
!this.site.mobileView
|
|
||||||
) {
|
|
||||||
this.appEvents.on(
|
|
||||||
"sidebar:docked-state-updated",
|
|
||||||
this,
|
|
||||||
"queueRerender"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dispatch("notifications:changed", "user-notifications");
|
this.dispatch("notifications:changed", "user-notifications");
|
||||||
this.dispatch("header:keyboard-trigger", "header");
|
this.dispatch("header:keyboard-trigger", "header");
|
||||||
this.dispatch("user-menu:navigation", "user-menu");
|
this.dispatch("user-menu:navigation", "user-menu");
|
||||||
|
@ -363,17 +352,6 @@ const SiteHeaderComponent = MountWidget.extend(
|
||||||
this.appEvents.off("user-menu:rendered", this, "_animateMenu");
|
this.appEvents.off("user-menu:rendered", this, "_animateMenu");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
this.currentUser?.experimental_sidebar_enabled &&
|
|
||||||
!this.site.mobileView
|
|
||||||
) {
|
|
||||||
this.appEvents.off(
|
|
||||||
"sidebar:docked-state-updated",
|
|
||||||
this,
|
|
||||||
"queueRerender"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.currentUser) {
|
if (this.currentUser) {
|
||||||
this.currentUser.off("status-changed", this, "queueRerender");
|
this.currentUser.off("status-changed", this, "queueRerender");
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,12 @@ export default Controller.extend({
|
||||||
discourseDebounce(this, this._mainOutletAnimate, 250);
|
discourseDebounce(this, this._mainOutletAnimate, 250);
|
||||||
|
|
||||||
this.toggleProperty("showSidebar");
|
this.toggleProperty("showSidebar");
|
||||||
this.appEvents.trigger("sidebar:docked-state-updated");
|
|
||||||
|
|
||||||
if (!this.site.mobileView) {
|
if (this.site.desktopView) {
|
||||||
|
this.appEvents.trigger("header:keyboard-trigger", {
|
||||||
|
type: "hamburger",
|
||||||
|
});
|
||||||
|
|
||||||
if (this.showSidebar) {
|
if (this.showSidebar) {
|
||||||
this.keyValueStore.removeItem(this.hideSidebarKey);
|
this.keyValueStore.removeItem(this.hideSidebarKey);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
@icon="keyboard"
|
@icon="keyboard"
|
||||||
@class="sidebar-footer-actions-button sidebar-footer-actions-keyboard-shortcuts" />
|
@class="sidebar-footer-actions-button sidebar-footer-actions-keyboard-shortcuts" />
|
||||||
|
|
||||||
{{#if this.site.desktopView}}
|
{{#if (and this.site.desktopView (not @sidebarDocked))}}
|
||||||
<DButton
|
<DButton
|
||||||
@action={{@toggleSidebar}}
|
@action={{@toggleSidebar}}
|
||||||
@icon="thumbtack"
|
@icon="thumbtack"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="panel-body-content">
|
<div class="panel-body-content">
|
||||||
<div class="sidebar-hamburger-dropdown">
|
<div class="sidebar-hamburger-dropdown">
|
||||||
<Sidebar::Sections @collapsableSections={{false}}/>
|
<Sidebar::Sections @collapsableSections={{false}}/>
|
||||||
<Sidebar::Footer @toggleSidebar={{route-action "toggleSidebar"}} @tagName="" />
|
<Sidebar::Footer @toggleSidebar={{route-action "toggleSidebar"}} @sidebarDocked={{@sidebarDocked}} @tagName="" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -244,34 +244,32 @@ createWidget("header-icons", {
|
||||||
|
|
||||||
icons.push(search);
|
icons.push(search);
|
||||||
|
|
||||||
if (!attrs.sidebarDocked) {
|
const hamburger = this.attach("header-dropdown", {
|
||||||
const hamburger = this.attach("header-dropdown", {
|
title: "hamburger_menu",
|
||||||
title: "hamburger_menu",
|
icon: "bars",
|
||||||
icon: "bars",
|
iconId: "toggle-hamburger-menu",
|
||||||
iconId: "toggle-hamburger-menu",
|
active: attrs.hamburgerVisible,
|
||||||
active: attrs.hamburgerVisible,
|
action: "toggleHamburger",
|
||||||
action: "toggleHamburger",
|
href: "",
|
||||||
href: "",
|
classNames: ["hamburger-dropdown"],
|
||||||
classNames: ["hamburger-dropdown"],
|
|
||||||
|
|
||||||
contents() {
|
contents() {
|
||||||
let { currentUser } = this;
|
let { currentUser } = this;
|
||||||
if (currentUser && currentUser.reviewable_count) {
|
if (currentUser && currentUser.reviewable_count) {
|
||||||
return h(
|
return h(
|
||||||
"div.badge-notification.reviewables",
|
"div.badge-notification.reviewables",
|
||||||
{
|
{
|
||||||
attributes: {
|
attributes: {
|
||||||
title: I18n.t("notifications.reviewable_items"),
|
title: I18n.t("notifications.reviewable_items"),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
this.currentUser.reviewable_count
|
},
|
||||||
);
|
this.currentUser.reviewable_count
|
||||||
}
|
);
|
||||||
},
|
}
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
icons.push(hamburger);
|
icons.push(hamburger);
|
||||||
}
|
|
||||||
|
|
||||||
if (attrs.user) {
|
if (attrs.user) {
|
||||||
icons.push(
|
icons.push(
|
||||||
|
@ -339,12 +337,15 @@ createWidget("revamped-hamburger-menu-wrapper", {
|
||||||
return { "data-click-outside": true };
|
return { "data-click-outside": true };
|
||||||
},
|
},
|
||||||
|
|
||||||
html() {
|
html(attrs) {
|
||||||
return [
|
return [
|
||||||
new RenderGlimmer(
|
new RenderGlimmer(
|
||||||
this,
|
this,
|
||||||
"div.widget-component-connector",
|
"div.widget-component-connector",
|
||||||
hbs`<Sidebar::HamburgerDropdown />`
|
hbs`<Sidebar::HamburgerDropdown @sidebarDocked={{@data.sidebarDocked}} />`,
|
||||||
|
{
|
||||||
|
sidebarDocked: attrs.sidebarDocked,
|
||||||
|
}
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
@ -402,10 +403,6 @@ export default createWidget("header", {
|
||||||
inTopicRoute = this.router.currentRouteName.startsWith("topic.");
|
inTopicRoute = this.router.currentRouteName.startsWith("topic.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrs.sidebarDocked) {
|
|
||||||
state.hamburgerVisible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let contents = () => {
|
let contents = () => {
|
||||||
const headerIcons = this.attach("header-icons", {
|
const headerIcons = this.attach("header-icons", {
|
||||||
hamburgerVisible: state.hamburgerVisible,
|
hamburgerVisible: state.hamburgerVisible,
|
||||||
|
@ -413,7 +410,6 @@ export default createWidget("header", {
|
||||||
searchVisible: state.searchVisible,
|
searchVisible: state.searchVisible,
|
||||||
ringBackdrop: state.ringBackdrop,
|
ringBackdrop: state.ringBackdrop,
|
||||||
flagCount: attrs.flagCount,
|
flagCount: attrs.flagCount,
|
||||||
sidebarDocked: attrs.sidebarDocked,
|
|
||||||
user: this.currentUser,
|
user: this.currentUser,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -431,7 +427,11 @@ export default createWidget("header", {
|
||||||
);
|
);
|
||||||
} else if (state.hamburgerVisible) {
|
} else if (state.hamburgerVisible) {
|
||||||
if (this.currentUser?.experimental_sidebar_enabled) {
|
if (this.currentUser?.experimental_sidebar_enabled) {
|
||||||
panels.push(this.attach("revamped-hamburger-menu-wrapper", {}));
|
panels.push(
|
||||||
|
this.attach("revamped-hamburger-menu-wrapper", {
|
||||||
|
sidebarDocked: attrs.sidebarDocked,
|
||||||
|
})
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
panels.push(this.attach("hamburger-menu"));
|
panels.push(this.attach("hamburger-menu"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,9 +399,9 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
||||||
|
|
||||||
await undockSidebar();
|
await undockSidebar();
|
||||||
|
|
||||||
assert.ok(
|
assert.strictEqual(
|
||||||
Object.keys(topicTrackingState.stateChangeCallbacks).length <
|
Object.keys(topicTrackingState.stateChangeCallbacks).length,
|
||||||
initialCallbackCount
|
initialCallbackCount
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -755,9 +755,9 @@ acceptance("Sidebar - Community Section", function (needs) {
|
||||||
|
|
||||||
await undockSidebar();
|
await undockSidebar();
|
||||||
|
|
||||||
assert.ok(
|
assert.strictEqual(
|
||||||
Object.keys(topicTrackingState.stateChangeCallbacks).length <
|
Object.keys(topicTrackingState.stateChangeCallbacks).length,
|
||||||
initialCallbackCount
|
initialCallbackCount
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -326,9 +326,9 @@ acceptance("Sidebar - Tags section", function (needs) {
|
||||||
|
|
||||||
await undockSidebar();
|
await undockSidebar();
|
||||||
|
|
||||||
assert.ok(
|
assert.strictEqual(
|
||||||
Object.keys(topicTrackingState.stateChangeCallbacks).length <
|
Object.keys(topicTrackingState.stateChangeCallbacks).length,
|
||||||
initialCallbackCount
|
initialCallbackCount
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,11 +90,9 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {
|
||||||
|
|
||||||
assert.ok(!exists(".sidebar-container"), "hides the sidebar");
|
assert.ok(!exists(".sidebar-container"), "hides the sidebar");
|
||||||
|
|
||||||
await click(".hamburger-dropdown");
|
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(".sidebar-hamburger-dropdown"),
|
exists(".sidebar-hamburger-dropdown"),
|
||||||
"displays the sidebar in hamburger dropdown"
|
"displays the sidebar in hamburger dropdown automatically after undocking"
|
||||||
);
|
);
|
||||||
|
|
||||||
await click("button.sidebar-footer-actions-dock-toggle");
|
await click("button.sidebar-footer-actions-dock-toggle");
|
||||||
|
@ -103,5 +101,22 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {
|
||||||
exists(".sidebar-container"),
|
exists(".sidebar-container"),
|
||||||
"displays the sidebar after docking"
|
"displays the sidebar after docking"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.notOk(
|
||||||
|
exists(".sidebar-hamburger-dropdown"),
|
||||||
|
"hides the sidebar in hamburger dropdown automatically after docking"
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".hamburger-dropdown");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists(".sidebar-hamburger-dropdown"),
|
||||||
|
"displays the sidebar in hamburger dropdown even when sidebar is docked"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.notOk(
|
||||||
|
exists(".sidebar-hamburger-dropdown .sidebar-footer-actions-dock-toggle"),
|
||||||
|
"does not display sidebar dock toggle in hamburger dropdown when sidebar is docked"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue