Browse files

ENHANCEMENT Allow opt-out of autofocus in CMS editor form, to avoid b…

…rowser "auto scrolling" to bring the focused element into view (fixes #7242)
  • Loading branch information...
1 parent 8c10539 commit e29bb3c39025f161aa7744b0de29bb9ec00cd96f @chillu chillu committed May 2, 2012
Showing with 6 additions and 3 deletions.
  1. +5 −2 admin/javascript/LeftAndMain.EditForm.js
  2. +1 −1 templates/Includes/
@@ -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}) {
@@ -1,7 +1,7 @@
<td class="bottom-all" colspan="$Colspan">
<div class="datagrid-pagination">
- $FirstPage $PreviousPage <span class="pagination-page-number">Page <input class="text" value="$CurrentPageNum"/> of $NumPages</span> $NextPage $LastPage
+ $FirstPage $PreviousPage <span class="pagination-page-number">Page <input class="text" value="$CurrentPageNum" data-skip-autofocus="true" /> of $NumPages</span> $NextPage $LastPage
<span class="pagination-records-number">View $FirstShownRecord - $LastShownRecord of $NumRecords</span>

0 comments on commit e29bb3c

Please sign in to comment.