mirror of
https://github.com/TryGhost/Ghost-Admin.git
synced 2023-12-14 02:33:04 +01:00
Koenig - Fix error when inserting cards in certain circumstances
refs https://github.com/TryGhost/Ghost/issues/9311 - the card selection in `cursorDidChange` would sometimes fail because the selection would be attempted before the newly inserted card had been pushed on to the `componentCards` array. This was reliably triggered by adding a card to a blank header section via the /-menu - scheduling the section `afterRender` ensures that the `willRender` hook has fired and populated the `componentCards` array before the selection occurs
This commit is contained in:
parent
55a99cb7c4
commit
2dd4305f76
|
@ -470,9 +470,13 @@ export default Component.extend({
|
|||
// select the card if the cursor is on the before/after ‌ char
|
||||
if (section && isCollapsed && section.type === 'card-section') {
|
||||
if (head.offset === 0 || head.offset === 1) {
|
||||
let card = this._getCardFromSection(section);
|
||||
this.selectCard(card);
|
||||
this.set('selectedRange', editor.range);
|
||||
// select card after render to ensure that our componentCards
|
||||
// attr is populated
|
||||
run.schedule('afterRender', this, () => {
|
||||
let card = this._getCardFromSection(section);
|
||||
this.selectCard(card);
|
||||
this.set('selectedRange', editor.range);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue