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