I have a long form and i am trying to focus the invalid fields with focus. I have a fixed header, so focusing input field is going below the header. Anyway to fix it?
I am using angular 1.5.7, ng-bootstrap, slimscroll in site.
I have a long form and i am trying to focus the invalid fields with focus. I have a fixed header, so focusing input field is going below the header. Anyway to fix it?
I am using angular 1.5.7, ng-bootstrap, slimscroll in site.
The best way is to create a directive which will handle this functionality. You can refer below stackoverflow link, which worked for me, illustrating how you can create the custom directive to set the focus.
Here is plunker for my comment
https://plnkr.co/edit/Ajoi66vkzsbxoiokLD93?p=preview
<input ng-focus="tc.onFocus()" type="text" />
vm.onFocus = function(){
var height = document.getElementsByTagName('header')[0].offsetHeight;
document.scrollHeight -= height;
}
Here is the main idea.
And btw, there is a good practice to add padding-top: fixed header height
to container after header.