Automatic scroll on element focus - potential to extend to include focused elements that are above the visible part of a scrollable region?

I’ve been doing a bit or work with forms in ionic and have noticed an inconsistency with how the automatic scroll feature is applied when an input field is focused. The scrolling works perfectly when you give focus to a field that is below the top of the visible part of a scrollable region, however the same is not true if the field is above the top of this region. You can easily reproduce this behaviour on a page with a series of input fields wrapped by an ion-content tag and by using the previous (<) and next (>) buttons on the virtual ios keyboard or by using tab and shift-tab on a normal keyboard to cycle focus through the fields.

Having had a look at the ionic code, js/utils/keyboard.js and js/views/scrollView.js, it seems a decision was made to apply auto scroll only when an element is below the visible part of the screen. It is quite easy to extend this feature to detect when a focused field is above and out of view, however perhaps there are undesirable implications of this approach.

I guess my question is whether this extension of functionality is recommended and if so should it belong in the core or should it be encapsulated in my own directive.

Hopefully the ionic gurus could provide an opinion on what the best cause of action is and whether there are performance or other reasons behind the current implementation.


I have seen this same behaviour too - it would be good to get a view on this - can anyone assist with the questions raised by @jeremy ?

Some further investigation reveals that this issue is only present when overflow scrolling is disabled, i.e. when cordova.plugins.Keyboard.disableScroll(true) is applied. However as per the “iOS Notes” of the Keyboard docs this is required to prevent headers jumping around when fields are focused.