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

Koenig - Fixed jump-to-top bug when focusing editor

refs https://github.com/TryGhost/Ghost/issues/9311
- the editor was being focused and the cursor placed properly but the act of focusing also reset the scroll position
- pulled the `.gh-koenig-editor` class into the component rather than leaving it in the template so that the component has access to `this.element`
- ensure the `.gh-koenig-editor` container is scrolled all the way to the bottom after focusing the editor
This commit is contained in:
Kevin Ansfield 2018-01-30 21:09:46 +00:00
parent d25fb1597e
commit cd0e7ebc64
2 changed files with 24 additions and 24 deletions

View file

@ -3,7 +3,7 @@ import Component from '@ember/component';
export default Component.extend({ export default Component.extend({
// public attrs // public attrs
tagName: '', classNames: ['gh-koenig-editor'],
title: '', title: '',
titlePlaceholder: '', titlePlaceholder: '',
body: null, body: null,
@ -35,6 +35,9 @@ export default Component.extend({
this._editor.run((postEditor) => { this._editor.run((postEditor) => {
postEditor.setRange(range.tail.section.tailPosition()); postEditor.setRange(range.tail.section.tailPosition());
}); });
// ensure we're scrolled to the bottom
this.element.scrollTop = this.element.scrollHeight;
} }
}, },

View file

@ -1,5 +1,3 @@
{{!-- scrollable container --}}
<div class="gh-koenig-editor">
{{!-- full height content pane --}} {{!-- full height content pane --}}
<div class="gh-koenig-editor-pane" onclick={{action "focusEditor"}}> <div class="gh-koenig-editor-pane" onclick={{action "focusEditor"}}>
{{gh-textarea title {{gh-textarea title
@ -22,4 +20,3 @@
didCreateEditor=(action "onEditorCreated") didCreateEditor=(action "onEditorCreated")
}} }}
</div> </div>
</div>