Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
503dcaca
Commit
503dcaca
authored
Sep 28, 2016
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly implement focus on first invalid.
parent
80cbc983
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
11 deletions
+6
-11
app/assets/javascripts/gl_field_errors.js.es6
app/assets/javascripts/gl_field_errors.js.es6
+6
-11
No files found.
app/assets/javascripts/gl_field_errors.js.es6
View file @
503dcaca
...
...
@@ -53,17 +53,16 @@
return this.setInvalidState();
}
this.form.focusOnFirstInvalid.apply(this.form);
}
handleInvalidInput(event) {
event.preventDefault();
const currentValue = this.inputElement.val();
this.state.valid = false;
this.state.empty =
false
;
this.state.empty =
currentValue === ''
;
this.renderValidity();
this.form.focusOnFirstInvalid.apply(this.form);
// For UX, wait til after first invalid submission to check each keyup
this.inputElement.off('keyup.field_validator')
.on('keyup.field_validator', this.updateValidityState.bind(this));
...
...
@@ -76,7 +75,7 @@
updateValidityState() {
const inputVal = this.inputElement.val();
this.state.empty = !
!
inputVal.length;
this.state.empty = !inputVal.length;
this.state.valid = this.getInputValidity();
this.renderValidity();
}
...
...
@@ -105,10 +104,6 @@
this.inputElement.siblings('p').hide();
this.fieldErrorElement.hide();
}
checkFieldValidity(target) {
return target.validity.valid;
}
}
const customValidationFlag = 'no-gl-field-errors';
...
...
@@ -144,8 +139,8 @@
}
focusOnFirstInvalid () {
const firstInvalid = this.state.inputs.fi
nd((input) => !input.inputDomElement.validity.valid)
;
$(firstInvalid)
.focus();
const firstInvalid = this.state.inputs.fi
lter((input) => !input.inputDomElement.validity.valid)[0]
;
firstInvalid.inputElement
.focus();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment