mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Koenig - Fix cards being deselected when clicking in edit mode
refs https://github.com/TryGhost/Ghost/issues/9311 - there was an issue where clicking inside a card whilst it was in edit mode would cause the cursor position in the editor to change from the end of a card to the beginning which would re-run our card selection routine and de-selecting the card - add a guard to the `cursorDidChange` method that looks for an end-to-beginning move whilst a card is in edit mode and ignores it
This commit is contained in:
parent
b3b07e488f
commit
26dd4ffb4a
1 changed files with 11 additions and 1 deletions
|
@ -406,6 +406,9 @@ export default Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
cursorDidChange(editor) {
|
cursorDidChange(editor) {
|
||||||
|
let {head, isCollapsed, head: {section}} = editor.range;
|
||||||
|
let selectedRange = this.get('selectedRange');
|
||||||
|
|
||||||
// sometimes we perform a programatic edit that causes a cursor change
|
// sometimes we perform a programatic edit that causes a cursor change
|
||||||
// but we actually want to skip the default behaviour because we've
|
// but we actually want to skip the default behaviour because we've
|
||||||
// already handled it, e.g. on card insertion, manual card selection
|
// already handled it, e.g. on card insertion, manual card selection
|
||||||
|
@ -415,7 +418,14 @@ export default Component.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let {head, isCollapsed, head: {section}} = editor.range;
|
// skip everything if the cursor is just moving from the end of a card
|
||||||
|
// section to the beginning whilst a card is in edit mode, this prevents
|
||||||
|
// clicks within a card causing the card to be deselected. Only applies
|
||||||
|
// when a card is in edit mode otherwise it's necessary to press LEFT
|
||||||
|
// twice to cycle up through cards
|
||||||
|
if (this._selectedCard && this._selectedCard.isEditing && selectedRange && isCollapsed && editor.range.headSection === selectedRange.headSection && editor.range.head.offset === 0 && selectedRange.head.offset === 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if we have a selected card but cursor has moved to the left then
|
// if we have a selected card but cursor has moved to the left then
|
||||||
// deselect and move cursor to end of the previous section
|
// deselect and move cursor to end of the previous section
|
||||||
|
|
Loading…
Add table
Reference in a new issue