UX: handle opening composer from slide-in hamburger menu (#159)
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
import { apiInitializer } from "discourse/lib/api";
|
||||||
|
|
||||||
|
export default apiInitializer("0.8", (api) => {
|
||||||
|
api.registerValueTransformer(
|
||||||
|
"hamburger-dropdown-click-outside-exceptions",
|
||||||
|
({ value }) => {
|
||||||
|
return [...value, ".topic-drafts-menu-content"];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -3,6 +3,7 @@ import { tracked } from "@glimmer/tracking";
|
|||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||||
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
|
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
|
||||||
|
import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
|
||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import { gt } from "truth-helpers";
|
import { gt } from "truth-helpers";
|
||||||
import CreateTopicButton from "discourse/components/create-topic-button";
|
import CreateTopicButton from "discourse/components/create-topic-button";
|
||||||
@@ -13,6 +14,8 @@ export default class SidebarNewTopicButton extends Component {
|
|||||||
@service currentUser;
|
@service currentUser;
|
||||||
@service siteSettings;
|
@service siteSettings;
|
||||||
@service router;
|
@service router;
|
||||||
|
@service header;
|
||||||
|
@service appEvents;
|
||||||
|
|
||||||
@tracked category;
|
@tracked category;
|
||||||
@tracked tag;
|
@tracked tag;
|
||||||
@@ -74,12 +77,30 @@ export default class SidebarNewTopicButton extends Component {
|
|||||||
this.tag = this.router.currentRoute.attributes?.tag || null;
|
this.tag = this.router.currentRoute.attributes?.tag || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
watchForComposer() {
|
||||||
|
// this covers opening drafts from the hamburger menu
|
||||||
|
this.appEvents.on("composer:will-open", this, this.closeHamburger);
|
||||||
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
stopWatchingForComposer() {
|
||||||
|
this.appEvents.off("composer:will-open", this, this.closeHamburger);
|
||||||
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
closeHamburger() {
|
||||||
|
this.header.hamburgerVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
{{#if this.shouldRender}}
|
{{#if this.shouldRender}}
|
||||||
<div
|
<div
|
||||||
class="sidebar-new-topic-button__wrapper"
|
class="sidebar-new-topic-button__wrapper"
|
||||||
{{didInsert this.getCategoryandTag}}
|
{{didInsert this.getCategoryandTag}}
|
||||||
{{didUpdate this.getCategoryandTag this.router.currentRoute}}
|
{{didUpdate this.getCategoryandTag this.router.currentRoute}}
|
||||||
|
{{didInsert this.watchForComposer}}
|
||||||
|
{{willDestroy this.stopWatchingForComposer}}
|
||||||
>
|
>
|
||||||
<CreateTopicButton
|
<CreateTopicButton
|
||||||
@canCreateTopic={{this.canCreateTopic}}
|
@canCreateTopic={{this.canCreateTopic}}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@use "lib/viewport";
|
||||||
|
|
||||||
.sidebar-wrapper,
|
.sidebar-wrapper,
|
||||||
.sidebar-hamburger-dropdown {
|
.sidebar-hamburger-dropdown {
|
||||||
@include breakpoint(medium) {
|
@include breakpoint(medium) {
|
||||||
@@ -80,3 +82,12 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// put the draft menu above the slide-out hamburger on small desktop screens
|
||||||
|
@include viewport.until(md) {
|
||||||
|
html:not(.mobile-view) {
|
||||||
|
.topic-drafts-menu-content {
|
||||||
|
z-index: z("modal", "overlay");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user