Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit f53db0f

Browse files
hyperrealitymleanos
authored andcommitted
Better autofocus (#1664)
1 parent d37b603 commit f53db0f

File tree

6 files changed

+8
-6
lines changed

6 files changed

+8
-6
lines changed

modules/articles/client/views/admin/form-article.client.view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h1>{{vm.article._id ? 'Edit Article' : 'New Article'}}</h1>
1212
<fieldset>
1313
<div class="form-group" show-errors>
1414
<label class="control-label" for="title">Title</label>
15-
<input name="title" type="text" ng-model="vm.article.title" id="title" class="form-control" placeholder="Title" required>
15+
<input name="title" type="text" ng-model="vm.article.title" id="title" class="form-control" placeholder="Title" required autofocus>
1616
<div ng-messages="vm.form.articleForm.title.$error" role="alert">
1717
<p class="help-block error-text" ng-message="required">Article title is required.</p>
1818
</div>

modules/core/client/directives/auto-focus.client.directive.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
function link(scope, element, attrs) {
2121
if ($window.innerWidth >= 800) {
2222
$timeout(function() {
23-
element[0].focus();
23+
var el = element[0];
24+
el.focus();
25+
el.selectionStart = el.selectionEnd = el.value.length;
2426
}, 100);
2527
}
2628
}

modules/users/client/views/admin/edit-user.client.view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h1>User <span ng-bind="vm.user.username"></span></h1>
77
<fieldset>
88
<div class="form-group" show-errors>
99
<label for="firstName">First Name</label>
10-
<input type="text" id="firstName" name="firstName" class="form-control" ng-model="vm.user.firstName" placeholder="First Name" required />
10+
<input type="text" id="firstName" name="firstName" class="form-control" ng-model="vm.user.firstName" placeholder="First Name" required autofocus />
1111
<div ng-messages="vm.userForm.firstName.$error" role="alert">
1212
<p class="help-block error-text" ng-message="required">First name is required.</p>
1313
</div>

modules/users/client/views/password/forgot-password.client.view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h3 class="col-md-12 text-center">Restore your password</h3>
55
<form name="vm.forgotPasswordForm" ng-submit="vm.askForPasswordReset(vm.forgotPasswordForm.$valid)" class="form-horizontal" novalidate autocomplete="off">
66
<fieldset>
77
<div class="form-group" show-errors>
8-
<input type="text" id="username" name="username" class="form-control" ng-model="vm.credentials.username" placeholder="Username" lowercase required>
8+
<input type="text" id="username" name="username" class="form-control" ng-model="vm.credentials.username" placeholder="Username" lowercase required autofocus>
99
<div ng-messages="vm.forgotPasswordForm.username.$error" role="alert">
1010
<p class="help-block error-text" ng-message="required">Enter a username.</p>
1111
</div>

modules/users/client/views/password/reset-password.client.view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h3 class="col-md-12 text-center">Reset your password</h3>
55
<fieldset>
66
<div class="form-group" show-errors>
77
<label for="newPassword">New Password</label>
8-
<input type="password" id="newPassword" name="newPassword" class="form-control" ng-model="vm.passwordDetails.newPassword" placeholder="New Password" autocomplete="new-password" uib-popover="{{vm.getPopoverMsg()}}" uib-popover-trigger="focus" uib-popover-placement="top" password-validator required>
8+
<input type="password" id="newPassword" name="newPassword" class="form-control" ng-model="vm.passwordDetails.newPassword" placeholder="New Password" autocomplete="new-password" uib-popover="{{vm.getPopoverMsg()}}" uib-popover-trigger="focus" uib-popover-placement="top" password-validator required autofocus>
99
<div ng-messages="vm.resetPasswordForm.newPassword.$error" role="alert">
1010
<p class="help-block error-text" ng-message="required">Enter a new password.</p>
1111
<div ng-repeat="passwordError in passwordErrors">

modules/users/client/views/settings/change-password.client.view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<fieldset>
55
<div class="form-group" show-errors>
66
<label for="currentPassword">Current Password</label>
7-
<input type="password" id="currentPassword" name="currentPassword" class="form-control" ng-model="vm.passwordDetails.currentPassword" placeholder="Current Password" required>
7+
<input type="password" id="currentPassword" name="currentPassword" class="form-control" ng-model="vm.passwordDetails.currentPassword" placeholder="Current Password" required autofocus>
88
<div ng-messages="vm.passwordForm.currentPassword.$error" role="alert">
99
<p class="help-block error-text" ng-message="required">Your current password is required.</p>
1010
</div>

0 commit comments

Comments
 (0)