{"action":"created","issue":{"url":"https://api.github.com/repos/ariatemplates/ariatemplates/issues/1434","labels_url":"https://api.github.com/repos/ariatemplates/ariatemplates/issues/1434/labels{/name}","comments_url":"https://api.github.com/repos/ariatemplates/ariatemplates/issues/1434/comments","events_url":"https://api.github.com/repos/ariatemplates/ariatemplates/issues/1434/events","html_url":"https://github.com/ariatemplates/ariatemplates/issues/1434","id":64702520,"number":1434,"title":"Input field not highlighted on error.","user":{"login":"gwbrown1968","id":11675469,"avatar_url":"https://avatars.githubusercontent.com/u/11675469?v=3","gravatar_id":"","url":"https://api.github.com/users/gwbrown1968","html_url":"https://github.com/gwbrown1968","followers_url":"https://api.github.com/users/gwbrown1968/followers","following_url":"https://api.github.com/users/gwbrown1968/following{/other_user}","gists_url":"https://api.github.com/users/gwbrown1968/gists{/gist_id}","starred_url":"https://api.github.com/users/gwbrown1968/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwbrown1968/subscriptions","organizations_url":"https://api.github.com/users/gwbrown1968/orgs","repos_url":"https://api.github.com/users/gwbrown1968/repos","events_url":"https://api.github.com/users/gwbrown1968/events{/privacy}","received_events_url":"https://api.github.com/users/gwbrown1968/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-27T06:00:11Z","updated_at":"2015-05-06T07:50:19Z","closed_at":"2015-05-06T07:50:19Z","body":"Hi, I work within Amadeus in Rail IT and we are seeing an issue where input fields that are in error are not highlighted with a red border when submit is triggered by an accelerator key. This only happens when the field being flagged in error has focus. Here are some example screenshots:\r\n\r\nBefore: Destination field has focus:\r\n![error1](https://cloud.githubusercontent.com/assets/11675469/6863119/d54b7866-d49f-11e4-96e3-5fadc8ed68dc.png)\r\nAfter 1: Clicking the Search button leads to the error popup being displayed and the field and label being highlighted in red: \r\n![error2](https://cloud.githubusercontent.com/assets/11675469/6863140/2b265d1e-d4a0-11e4-8a68-e32497c8c21f.png)\r\nAfter 2: Using the accelerator keys Alt-Shift-S to do the search leads to the error popup being displayed, but the field and label are not highlighted in red.\r\n![error3](https://cloud.githubusercontent.com/assets/11675469/6863193/e893ad48-d4a0-11e4-819e-b2d02664dfb3.png)\r\n\r\nWe are using Aria Templates version 1.7.1. The issue occurs on all browsers. \r\n\r\nThe destination field is an aria AutoComplete widget but the same error occurs on a DatePicker widget. In our code the destination field has a Mandatory validator set as follows:\r\n*dataUtils.setValidator(searchFields, \"destinationStnCd\", new Mandatory(this.properties.getProperty(\"errors.availability.noDestinationStationSelected\")));*\r\n\r\nThe accelerator keys are set via the NavigationManager:\r\n*NavigationManager.addGlobalKeyMap({key : \"S\", alt : true, shift : useShift, callback : {fn : \"doSearch\", scope : moduleCtrl}});*\r\n\r\nCould someone please investigate this error and let me know if you need any more information.\r\n\r\nThanks\r\nGraeme Brown\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ariatemplates/ariatemplates/issues/comments/99360155","html_url":"https://github.com/ariatemplates/ariatemplates/issues/1434#issuecomment-99360155","issue_url":"https://api.github.com/repos/ariatemplates/ariatemplates/issues/1434","id":99360155,"user":{"login":"divdavem","id":1152706,"avatar_url":"https://avatars.githubusercontent.com/u/1152706?v=3","gravatar_id":"","url":"https://api.github.com/users/divdavem","html_url":"https://github.com/divdavem","followers_url":"https://api.github.com/users/divdavem/followers","following_url":"https://api.github.com/users/divdavem/following{/other_user}","gists_url":"https://api.github.com/users/divdavem/gists{/gist_id}","starred_url":"https://api.github.com/users/divdavem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/divdavem/subscriptions","organizations_url":"https://api.github.com/users/divdavem/orgs","repos_url":"https://api.github.com/users/divdavem/repos","events_url":"https://api.github.com/users/divdavem/events{/privacy}","received_events_url":"https://api.github.com/users/divdavem/received_events","type":"User","site_admin":false},"created_at":"2015-05-06T07:50:19Z","updated_at":"2015-05-06T07:50:19Z","body":"Hi Graeme,\r\n\r\nI have investigated the issue.\r\n\r\nHere is what happens:\r\n- the field is focused\r\n- the user presses Alt-Shift-S\r\n- `doSearch` is called\r\n- from `doSearch`, `aria.utils.Data.validateModel` is called\r\n- errors are correctly set on all fields by `validateModel`, including to\r\nthe focused field\r\n- `doSearch` checks if there is any error, and, as there is at least one, it triggers the display of the modal dialog\r\n- when the modal dialog is displayed, the field is blurred to give the focus to the button inside the dialog\r\n- as part of the blur process on the field, the error is removed from the field. This is the normal behavior of fields in error for which no validation happens on blur, so that the user does not think the entry is wrong when it was simply not validated. Maybe we should check whether the value was modified and only remove the error in that case, that is a possibility.\r\n\r\nHowever, I think that the root cause of the problem is the fact that the validation happens while the field is focused.\r\nDoing the validation while the field is focused triggers another issue: if the user has typed something in the field just before pressing Alt-Shift-S, what is in the field is not yet in the data model and is not taken into account during the validation, because the content of the data model is updated only on blur.\r\n\r\nSo, the solution is to blur any field before doing the validation.\r\n\r\nYou can do so by executing the following code just before your `doSearch` function is called:\r\n\r\n```js\r\n    if (document.activeElement) {\r\n        document.activeElement.blur();\r\n    }\r\n```\r\n\r\nIt should solve the issue.\r\n\r\nBest regards,\r\n\r\nDavid-Emmanuel\r\n"}}