Skip to content

Commit

Permalink
Remove messageBox input reference from popover
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Mar 29, 2019
1 parent 05c83cd commit 3c94b52
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
8 changes: 4 additions & 4 deletions app/ui-message/client/messageBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{else}}
{{#if subscribed}}
{{> messageBoxAudioMessage rid=_id}}
<span class="rc-message-box__action-menu" data-desktop>
<span class="rc-message-box__action-menu js-action-menu" data-desktop>
{{#if actions}}
<span class="rc-message-box__icon">
{{> icon block="rc-input__icon-svg" icon="plus"}}
Expand All @@ -41,9 +41,9 @@
{{/if}}
{{/unless}}
<span class="rc-message-box__action-label js-message-actions" data-small>
{{#each actions}}
<span class="js-message-action">
{{> icon block="rc-message-box__action" icon=icon }}
{{#each action in actions}}
<span class="js-message-action" data-id="{{action.id}}">
{{> icon block="rc-message-box__action" icon=action.icon }}
</span>
{{/each}}
</span>
Expand Down
20 changes: 13 additions & 7 deletions app/ui-message/client/messageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Template.messageBox.events({
input.focus();
});
},
'click .rc-message-box__action-menu'(event) {
'click .js-action-menu'(event, instance) {
const groups = messageBox.actions.get();
const config = {
popoverClass: 'message-box',
Expand Down Expand Up @@ -409,19 +409,25 @@ Template.messageBox.events({
currentTarget: event.currentTarget.firstElementChild.firstElementChild,
data: {
rid: this._id,
messageBox: instance.firstNode,
},
activeElement: event.currentTarget,
};

popover.open(config);
},
'click .js-message-actions .js-message-action'(event, instance) {
this.action.apply(this, [{
rid: Template.parentData()._id,
messageBox: instance.find('.rc-message-box'),
element: event.currentTarget,
event,
}]);
const { id } = event.currentTarget.dataset;
const actions = messageBox.actions.getById(id);
actions
.filter(({ action }) => !!action)
.forEach(({ action }) => {
action.call(null, {
rid: this._id,
messageBox: instance.firstNode,
event,
});
});
},
'click .js-format'(e, t) {
applyFormatting.apply(this, [e, t]);
Expand Down
17 changes: 10 additions & 7 deletions app/ui-utils/client/lib/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,16 @@ Template.popover.events({
},
'click [data-type="messagebox-action"]'(event, t) {
const { id } = event.currentTarget.dataset;
const action = messageBox.actions.getById(id);
if ((action[0] != null ? action[0].action : undefined) != null) {
action[0].action({ rid: t.data.data.rid, ...t.data.data, messageBox: document.querySelector('.rc-message-box'), element: event.currentTarget, event });
if (id !== 'audio-message') {
popover.close();
}
}
const actions = messageBox.actions.getById(id);
actions
.filter(({ action }) => !!action)
.forEach(({ action }) => {
action.call(null, {
...t.data.data,
event,
});
});
popover.close();
},
'click [data-type="message-action"]'(e, t) {
const button = MessageAction.getButtonById(e.currentTarget.dataset.id);
Expand Down

0 comments on commit 3c94b52

Please sign in to comment.