diff --git a/src/public/app/widgets/attribute_widgets/attribute_editor.js b/src/public/app/widgets/attribute_widgets/attribute_editor.js index 433b4005a..614e74eb2 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_editor.js +++ b/src/public/app/widgets/attribute_widgets/attribute_editor.js @@ -497,6 +497,16 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget { await this.renderOwnedAttributes(attributes, false); } + focus() { + this.$editor.trigger('focus'); + + this.textEditor.model.change( writer => { + const positionAt = writer.createPositionAt(this.textEditor.model.document.getRoot(), 'end'); + + writer.setSelection(positionAt); + } ); + } + entitiesReloadedEvent({loadResults}) { if (loadResults.getAttributes(this.componentId).find(attr => attributeService.isAffecting(attr, this.note))) { this.refresh(); diff --git a/src/public/app/widgets/containers/ribbon_container.js b/src/public/app/widgets/containers/ribbon_container.js index 550287807..a344bef3a 100644 --- a/src/public/app/widgets/containers/ribbon_container.js +++ b/src/public/app/widgets/containers/ribbon_container.js @@ -186,7 +186,9 @@ export default class RibbonContainer extends NoteContextAwareWidget { const activeChild = this.getActiveRibbonWidget(); if (activeChild && (refreshActiveTab || !wasAlreadyActive)) { - activeChild.handleEvent('noteSwitched', {noteContext: this.noteContext, notePath: this.notePath}); + activeChild.handleEvent('noteSwitched', {noteContext: this.noteContext, notePath: this.notePath}).then(() => { + activeChild.focus?.(); + }); } } else { this.lastActiveComponentId = null; diff --git a/src/public/app/widgets/ribbon_widgets/owned_attribute_list.js b/src/public/app/widgets/ribbon_widgets/owned_attribute_list.js index 4f294979d..da8ed35ba 100644 --- a/src/public/app/widgets/ribbon_widgets/owned_attribute_list.js +++ b/src/public/app/widgets/ribbon_widgets/owned_attribute_list.js @@ -82,4 +82,8 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget { this.getTitle(this.note); } } + + focus() { + this.attributeEditorWidget.focus(); + } } diff --git a/src/public/app/widgets/ribbon_widgets/promoted_attributes.js b/src/public/app/widgets/ribbon_widgets/promoted_attributes.js index d35fe4f0f..6c6e58495 100644 --- a/src/public/app/widgets/ribbon_widgets/promoted_attributes.js +++ b/src/public/app/widgets/ribbon_widgets/promoted_attributes.js @@ -310,6 +310,10 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget { $attr.attr("data-attribute-id", result.attributeId); } + focus() { + this.$widget.find(".promoted-attribute-input:first").focus(); + } + entitiesReloadedEvent({loadResults}) { if (loadResults.getAttributes(this.componentId).find(attr => attributeService.isAffecting(attr, this.note))) { this.refresh();