🐛 Koenig - Fixed error when clicking embed icons in /-menu

refs https://github.com/TryGhost/Ghost/issues/9724
- `{{koenig-menu-content}}` does not pass any params through when an item is clicked
- move the `params` fetching via the query string from `_performAction()` to `actions.itemClicked` so that it works for both <kbd>Enter</kbd> and icon clicks
This commit is contained in:
Kevin Ansfield 2018-07-17 14:32:49 +01:00
parent 1027f85a68
commit 8a76e5346a

View File

@ -88,12 +88,13 @@ export default Component.extend({
}, },
actions: { actions: {
itemClicked(item, params) { itemClicked(item) {
let range = this._openRange.head.section.toRange(); let range = this._openRange.head.section.toRange();
let [, ...params] = this._query.split(/\s/);
let payload; let payload;
// params are order-dependent and listed in CARD_MENU for each card // params are order-dependent and listed in CARD_MENU for each card
if (item.params) { if (!isEmpty(item.params) && !isEmpty(params)) {
payload = {}; payload = {};
item.params.forEach((param, i) => { item.params.forEach((param, i) => {
payload[param] = params[i]; payload[param] = params[i];
@ -274,10 +275,9 @@ export default Component.extend({
_performAction() { _performAction() {
let selectedItem = this._getSelectedItem(); let selectedItem = this._getSelectedItem();
let [, ...params] = this._query.split(/\s/);
if (selectedItem) { if (selectedItem) {
this.send('itemClicked', selectedItem, params); this.send('itemClicked', selectedItem);
} }
}, },