mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
Now that we correctly await for the modal to close, we dont need to special case and disable focusTrigger, the flow will now be: - click an element of the menu - wait for modal to close - focus trigger - trigger action, which will eventually open a modal and attempt to focus the first item
55 lines
1.6 KiB
Plaintext
55 lines
1.6 KiB
Plaintext
import Component from "@glimmer/component";
|
|
import { array, fn } from "@ember/helper";
|
|
import { action } from "@ember/object";
|
|
import DButton from "discourse/components/d-button";
|
|
import concatClass from "discourse/helpers/concat-class";
|
|
import { i18n } from "discourse-i18n";
|
|
import DMenu from "float-kit/components/d-menu";
|
|
|
|
export default class ChatComposerDropdown extends Component {
|
|
@action
|
|
async onButtonClick(button, closeFn) {
|
|
await closeFn();
|
|
|
|
button.action();
|
|
}
|
|
|
|
<template>
|
|
{{#if @buttons.length}}
|
|
<DMenu
|
|
class={{concatClass
|
|
"chat-composer-dropdown__trigger-btn"
|
|
"btn-flat"
|
|
(if @hasActivePanel "has-active-panel")
|
|
}}
|
|
@title={{i18n "chat.composer.toggle_toolbar"}}
|
|
@icon="plus"
|
|
@disabled={{@isDisabled}}
|
|
@arrow={{true}}
|
|
@placements={{array "top" "bottom"}}
|
|
@identifier="chat-composer-dropdown__menu"
|
|
@modalForMobile={{true}}
|
|
...attributes
|
|
as |menu|
|
|
>
|
|
<ul class="chat-composer-dropdown__list">
|
|
{{#each @buttons as |button|}}
|
|
<li class={{concatClass "chat-composer-dropdown__item" button.id}}>
|
|
<DButton
|
|
@icon={{button.icon}}
|
|
@action={{fn this.onButtonClick button menu.close}}
|
|
@label={{button.label}}
|
|
class={{concatClass
|
|
"chat-composer-dropdown__action-btn"
|
|
"btn-transparent"
|
|
button.id
|
|
}}
|
|
/>
|
|
</li>
|
|
{{/each}}
|
|
</ul>
|
|
</DMenu>
|
|
{{/if}}
|
|
</template>
|
|
}
|