0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Koenig - Fixed error when clicking on card with /-menu open

refs https://github.com/TryGhost/Ghost/issues/9505
- logic assumed that the selected section had a text property (cards do not)
This commit is contained in:
Kevin Ansfield 2018-04-25 15:19:09 +01:00
parent ec65fc890b
commit 13c402cfe8

View file

@ -111,20 +111,24 @@ export default Component.extend({
// update menu position to match cursor position // update menu position to match cursor position
this._positionMenu(editorRange); this._positionMenu(editorRange);
if (this.get('showMenu') && editorRange) {
let {head: {section}} = editorRange;
// close the menu if we're on a non-slash section (eg, when / is deleted) // close the menu if we're on a non-slash section (eg, when / is deleted)
if (this.get('showMenu') && editorRange.head.section && editorRange.head.section.text.indexOf('/') !== 0) { if (section && section.text && section.text.indexOf('/') !== 0) {
this._hideMenu(); this._hideMenu();
return; return;
} }
// update the query when the menu is open and cursor is in our open range // update the query when the menu is open and cursor is in our open range
if (this.get('showMenu') && editorRange.head.section === this._openRange.head.section) { if (section === this._openRange.head.section) {
let query = editorRange.head.section.text.substring( let query = section.text.substring(
this._openRange.head.offset, this._openRange.head.offset,
editorRange.head.offset editorRange.head.offset
); );
this._updateQuery(query); this._updateQuery(query);
} }
}
}, },
_updateQuery(query) { _updateQuery(query) {