1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

🐝 Fix editor toolbar link focus issues. (#599)

closes https://github.com/TryGhost/Ghost/issues/8195

When the toolbar is toggled into link mode the link input field should always focus, however this only happens on the first time which leads to issues with mobiledoc having focus but not the range.

This fix means that the toolbar always focuses.
This commit is contained in:
Ryan McCarvill 2017-03-22 02:52:47 +13:00 committed by Kevin Ansfield
parent ab118ba572
commit 72c0694b4a
2 changed files with 12 additions and 8 deletions

View file

@ -101,14 +101,18 @@ export default Component.extend({
event.stopPropagation();
}
},
doLink(range) {
this.set('isLink', true);
this.set('linkRange', range);
run.schedule('afterRender', this,
() => {
this.$('input').focus();
}
);
},
closeLink() {
this.set('isLink', false);
}
},
doLink(range) {
this.set('isLink', true);
this.set('linkRange', range);
}
});
@ -140,7 +144,7 @@ function updateToolbarToRange(self, $holder, $editor, isMouseDown) {
}
);
self.set('isLink', false);
self.send('closeLink');
self.tools.forEach((tool) => {
if (tool.hasOwnProperty('checkElements')) {
@ -152,7 +156,7 @@ function updateToolbarToRange(self, $holder, $editor, isMouseDown) {
} else {
if (self.isVisible) {
self.set('isVisible', false);
self.set('isLink', false);
self.send('closeLink');
}
}

View file

@ -182,7 +182,7 @@ export default function (editor, toolbar) {
type: 'markup',
visibility: 'primary',
onClick: (editor) => {
toolbar.doLink(editor.range);
toolbar.send('doLink', editor.range);
},
checkElements(elements) {
set(this, 'selected', elements.filter((element) => element.tagName === 'a').length > 0);