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:
parent
ec65fc890b
commit
13c402cfe8
1 changed files with 16 additions and 12 deletions
|
@ -111,19 +111,23 @@ export default Component.extend({
|
||||||
// update menu position to match cursor position
|
// update menu position to match cursor position
|
||||||
this._positionMenu(editorRange);
|
this._positionMenu(editorRange);
|
||||||
|
|
||||||
// close the menu if we're on a non-slash section (eg, when / is deleted)
|
if (this.get('showMenu') && editorRange) {
|
||||||
if (this.get('showMenu') && editorRange.head.section && editorRange.head.section.text.indexOf('/') !== 0) {
|
let {head: {section}} = editorRange;
|
||||||
this._hideMenu();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the query when the menu is open and cursor is in our open range
|
// close the menu if we're on a non-slash section (eg, when / is deleted)
|
||||||
if (this.get('showMenu') && editorRange.head.section === this._openRange.head.section) {
|
if (section && section.text && section.text.indexOf('/') !== 0) {
|
||||||
let query = editorRange.head.section.text.substring(
|
this._hideMenu();
|
||||||
this._openRange.head.offset,
|
return;
|
||||||
editorRange.head.offset
|
}
|
||||||
);
|
|
||||||
this._updateQuery(query);
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue