From e29bb3c39025f161aa7744b0de29bb9ec00cd96f Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 2 May 2012 18:27:45 +0200 Subject: [PATCH] ENHANCEMENT Allow opt-out of autofocus in CMS editor form, to avoid browser "auto scrolling" to bring the focused element into view (fixes #7242) --- admin/javascript/LeftAndMain.EditForm.js | 7 +++++-- templates/Includes/GridFieldPaginator_Row.ss | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/admin/javascript/LeftAndMain.EditForm.js b/admin/javascript/LeftAndMain.EditForm.js index ef4b660e7..e440801d8 100644 --- a/admin/javascript/LeftAndMain.EditForm.js +++ b/admin/javascript/LeftAndMain.EditForm.js @@ -64,8 +64,11 @@ // in order to avoid changing the menu state if the action is cancelled by the user // $('.cms-menu') - // focus input on first form element - this.find(':input:visible:not(:submit):first').focus(); + // focus input on first form element. Exclude elements which + // specifically opt-out of this behaviour via "data-skip-autofocus". + // This opt-out is useful if the first visible field is shown far down a scrollable area, + // for example for the pagination input field after a long GridField listing. + this.find(':input:visible:not(:submit)[data-skip-autofocus!="true"]:first').focus(); // Optionally get the form attributes from embedded fields, see Form->formHtmlContent() for(var overrideAttr in {'action':true,'method':true,'enctype':true,'name':true}) { diff --git a/templates/Includes/GridFieldPaginator_Row.ss b/templates/Includes/GridFieldPaginator_Row.ss index f21bf1a48..ee246c129 100644 --- a/templates/Includes/GridFieldPaginator_Row.ss +++ b/templates/Includes/GridFieldPaginator_Row.ss @@ -1,7 +1,7 @@
- $FirstPage $PreviousPage Page of $NumPages $NextPage $LastPage + $FirstPage $PreviousPage Page of $NumPages $NextPage $LastPage
View $FirstShownRecord - $LastShownRecord of $NumRecords