focus promoted/owned attributes input after activating the ribbon tab, closes #2606

This commit is contained in:
zadam 2022-02-01 20:24:58 +01:00
parent be44431fde
commit 46eaa63625
6 changed files with 31 additions and 11 deletions

18
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "trilium",
"version": "0.49.4",
"version": "0.49.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "trilium",
"version": "0.49.4",
"version": "0.49.5",
"license": "AGPL-3.0-only",
"dependencies": {
"@electron/remote": "2.0.1",
@ -71,7 +71,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "16.0.6",
"electron": "16.0.8",
"electron-builder": "22.14.5",
"electron-packager": "15.4.0",
"electron-rebuild": "3.2.5",
@ -3713,9 +3713,9 @@
}
},
"node_modules/electron": {
"version": "16.0.6",
"resolved": "https://registry.npmjs.org/electron/-/electron-16.0.6.tgz",
"integrity": "sha512-Xs9dYLYhcJf3wXn8m2gDqFTb1L862KEhMxOx9swfFBHj6NoUPPtUgw/RyPQ0tXN1XPxG9vnBkoI0BdcKwrLKuQ==",
"version": "16.0.8",
"resolved": "https://registry.npmjs.org/electron/-/electron-16.0.8.tgz",
"integrity": "sha512-znTVkl8LaGcPNdfc6SRr+6LYg2GtSCKXln/nW/PC+urBfAFnOYIuDock8QyGVFfzr5PuAa+g8YQQAboHV77D7g==",
"hasInstallScript": true,
"dependencies": {
"@electron/get": "^1.13.0",
@ -14169,9 +14169,9 @@
}
},
"electron": {
"version": "16.0.6",
"resolved": "https://registry.npmjs.org/electron/-/electron-16.0.6.tgz",
"integrity": "sha512-Xs9dYLYhcJf3wXn8m2gDqFTb1L862KEhMxOx9swfFBHj6NoUPPtUgw/RyPQ0tXN1XPxG9vnBkoI0BdcKwrLKuQ==",
"version": "16.0.8",
"resolved": "https://registry.npmjs.org/electron/-/electron-16.0.8.tgz",
"integrity": "sha512-znTVkl8LaGcPNdfc6SRr+6LYg2GtSCKXln/nW/PC+urBfAFnOYIuDock8QyGVFfzr5PuAa+g8YQQAboHV77D7g==",
"requires": {
"@electron/get": "^1.13.0",
"@types/node": "^14.6.2",

View File

@ -83,7 +83,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "16.0.6",
"electron": "16.0.8",
"electron-builder": "22.14.5",
"electron-packager": "15.4.0",
"electron-rebuild": "3.2.5",

View File

@ -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();

View File

@ -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;

View File

@ -82,4 +82,8 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget {
this.getTitle(this.note);
}
}
focus() {
this.attributeEditorWidget.focus();
}
}

View File

@ -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();