mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-24 12:21:22 -05:00
Merge pull request #2880 from alphagov/add-logic-to-autofocus
Prevent autofocus when page has scrolled
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
|
||||
Modules.Autofocus = function() {
|
||||
this.start = function(component) {
|
||||
var forceFocus = $(component).data('forceFocus');
|
||||
|
||||
// if the page loads with a scroll position, we can't assume the item to focus onload
|
||||
// is still where users intend to start
|
||||
if (($(window).scrollTop() > 0) && !forceFocus) { return; }
|
||||
|
||||
$('input, textarea, select', component).eq(0).trigger('focus');
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
{% call form_wrapper(
|
||||
class='js-stick-at-top-when-scrolling send-one-off-form' if template.template_type != 'sms' else 'send-one-off-form',
|
||||
module="autofocus"
|
||||
module="autofocus",
|
||||
data_kwargs={'force-focus': True}
|
||||
) %}
|
||||
<div class="grid-row">
|
||||
<div class="column-two-thirds {% if form.placeholder_value.label.text == 'phone number' %}extra-tracking{% endif %}">
|
||||
|
||||
Reference in New Issue
Block a user