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,25 +1,22 @@
{{!-- scrollable container --}} {{!-- full height content pane --}}
<div class="gh-koenig-editor"> <div class="gh-koenig-editor-pane" onclick={{action "focusEditor"}}>
{{!-- full height content pane --}} {{gh-textarea title
<div class="gh-koenig-editor-pane" onclick={{action "focusEditor"}}> class="gh-editor-title"
{{gh-textarea title placeholder=titlePlaceholder
class="gh-editor-title" tabindex="1"
placeholder=titlePlaceholder autoExpand=".gh-koenig-editor"
tabindex="1" update=(action "onTitleChange")
autoExpand=".gh-koenig-editor" focusOut=(action "onTitleFocusOut")
update=(action "onTitleChange") keyDown=(action "onTitleKeydown")
focusOut=(action "onTitleFocusOut") didCreateTextarea=(action "onTitleCreated")
keyDown=(action "onTitleKeydown") }}
didCreateTextarea=(action "onTitleCreated")
}}
{{koenig-editor {{koenig-editor
mobiledoc=body mobiledoc=body
placeholder=bodyPlaceholder placeholder=bodyPlaceholder
autofocus=bodyAutofocus autofocus=bodyAutofocus
spellcheck=true spellcheck=true
onChange=(action "onBodyChange") onChange=(action "onBodyChange")
didCreateEditor=(action "onEditorCreated") didCreateEditor=(action "onEditorCreated")
}} }}
</div>
</div> </div>