Auto focus on the first input field
When opening the Create New dialog in Browse > Repositories and Browse > Groups, auto focus on the first input field to avoid unnecessary clicks. Bug: Issue 12536 Change-Id: Ieae5f1e5eac1cd51a101cc7fcab4a1d78582faaf
This commit is contained in:
@@ -178,7 +178,9 @@ export class GrAdminGroupList extends ListViewMixin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleCreateClicked() {
|
_handleCreateClicked() {
|
||||||
this.$.createOverlay.open();
|
this.$.createOverlay.open().then(() => {
|
||||||
|
this.$.createNewModal.focus();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_visibleToAll(item: GroupInfo) {
|
_visibleToAll(item: GroupInfo) {
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ suite('gr-admin-group-list tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('_handleCreateClicked opens modal', () => {
|
test('_handleCreateClicked opens modal', () => {
|
||||||
const openStub = sinon.stub(element.$.createOverlay, 'open');
|
const openStub = sinon.stub(element.$.createOverlay, 'open').returns(
|
||||||
|
Promise.resolve());
|
||||||
element._handleCreateClicked();
|
element._handleCreateClicked();
|
||||||
assert.isTrue(openStub.called);
|
assert.isTrue(openStub.called);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ export class GrCreateGroupDialog extends GestureEventListeners(
|
|||||||
this.hasNewGroupName = !!name;
|
this.hasNewGroupName = !!name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focus() {
|
||||||
|
this.shadowRoot?.querySelector('input')?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
handleCreateGroup() {
|
handleCreateGroup() {
|
||||||
const name = this._name as GroupName;
|
const name = this._name as GroupName;
|
||||||
return this.restApiService.createGroup({name}).then(groupRegistered => {
|
return this.restApiService.createGroup({name}).then(groupRegistered => {
|
||||||
|
|||||||
@@ -83,6 +83,10 @@ export class GrCreateRepoDialog extends GestureEventListeners(
|
|||||||
return getBaseUrl() + '/admin/repos/' + encodeURL(repoName, true);
|
return getBaseUrl() + '/admin/repos/' + encodeURL(repoName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focus() {
|
||||||
|
this.shadowRoot?.querySelector('input')?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
@observe('_repoConfig.name')
|
@observe('_repoConfig.name')
|
||||||
_updateRepoName(name: string) {
|
_updateRepoName(name: string) {
|
||||||
this.hasNewRepoName = !!name;
|
this.hasNewRepoName = !!name;
|
||||||
|
|||||||
@@ -169,7 +169,9 @@ export class GrRepoList extends ListViewMixin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleCreateClicked() {
|
_handleCreateClicked() {
|
||||||
this.$.createOverlay.open();
|
this.$.createOverlay.open().then(() => {
|
||||||
|
this.$.createNewModal.focus();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_readOnly(repo: ProjectInfoWithName) {
|
_readOnly(repo: ProjectInfoWithName) {
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ suite('gr-repo-list tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('_handleCreateClicked opens modal', () => {
|
test('_handleCreateClicked opens modal', () => {
|
||||||
const openStub = sinon.stub(element.$.createOverlay, 'open');
|
const openStub = sinon.stub(element.$.createOverlay, 'open').returns(
|
||||||
|
Promise.resolve());
|
||||||
element._handleCreateClicked();
|
element._handleCreateClicked();
|
||||||
assert.isTrue(openStub.called);
|
assert.isTrue(openStub.called);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user