UX: handle opening composer from slide-in hamburger menu (#159)
This commit is contained in:
@@ -3,6 +3,7 @@ import { tracked } from "@glimmer/tracking";
|
||||
import { action } from "@ember/object";
|
||||
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
|
||||
import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
|
||||
import { service } from "@ember/service";
|
||||
import { gt } from "truth-helpers";
|
||||
import CreateTopicButton from "discourse/components/create-topic-button";
|
||||
@@ -13,6 +14,8 @@ export default class SidebarNewTopicButton extends Component {
|
||||
@service currentUser;
|
||||
@service siteSettings;
|
||||
@service router;
|
||||
@service header;
|
||||
@service appEvents;
|
||||
|
||||
@tracked category;
|
||||
@tracked tag;
|
||||
@@ -74,12 +77,30 @@ export default class SidebarNewTopicButton extends Component {
|
||||
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>
|
||||
{{#if this.shouldRender}}
|
||||
<div
|
||||
class="sidebar-new-topic-button__wrapper"
|
||||
{{didInsert this.getCategoryandTag}}
|
||||
{{didUpdate this.getCategoryandTag this.router.currentRoute}}
|
||||
{{didInsert this.watchForComposer}}
|
||||
{{willDestroy this.stopWatchingForComposer}}
|
||||
>
|
||||
<CreateTopicButton
|
||||
@canCreateTopic={{this.canCreateTopic}}
|
||||
|
||||
Reference in New Issue
Block a user