Commit 0720b44a authored by Aron Carroll's avatar Aron Carroll Committed by Randall Leeds

Fix for error states on logout/login

This fixes an issue where logging in, then logging out and opening
the login form will reveal a form with error messages. This is due
to the execution order of events post login.

https://github.com/hypothesis/h/pull/1275#issuecomment-51777983
parent e6f6987d
......@@ -48,6 +48,11 @@ formValidate = ['$timeout', ($timeout) ->
isSubmitted = false
, true
scope.$watch form.$name + '.$pristine', (value) ->
if value == true
forEachField (field) ->
toggleClass(field, addClass: false)
require: 'form'
]
......
......@@ -121,6 +121,21 @@ describe 'h.directives', ->
assert.notInclude($field.prop('className'), 'form-field-error')
# No idea why this is failing, it works for the login form...
it 'should hide errors if the field is pristine', ->
$field = $element.find('.form-field').addClass('form-field-error')
$input = $element.find('[name=username]')
formController = $input.controller('form')
modelController = $input.controller('ngModel')
modelController.$setViewValue('a') # Change the model state to $dirty
# Clear out the model and set to $pristine
$scope.model = {}
formController.$setPristine()
assert.notInclude($field.prop('className'), 'form-field-error')
describe '.username', ->
$element = null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment