From 81a217e06bf964113a2349b8433295dce787110c Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 17 Mar 2023 13:00:52 -0700 Subject: [PATCH] Reintroduce autofocus for now Reverts #12332 Reverts #12406 Resolves #12921 --- CHANGELOG.md | 1 + src/fieldlayoutelements/TitleField.php | 2 +- src/templates/settings/assets/volumes/_edit.twig | 1 + src/templates/settings/categories/_edit.twig | 1 + src/templates/settings/email/_index.twig | 1 + src/templates/settings/fields/_edit.twig | 1 + src/templates/settings/filesystems/_edit.twig | 1 + src/templates/settings/globals/_edit.twig | 1 + src/templates/settings/sections/_edit.twig | 1 + src/templates/settings/sites/_edit.twig | 1 + src/templates/settings/tags/_edit.twig | 1 + src/templates/users/_accountfields.twig | 1 + src/web/assets/cp/dist/cp.js | 2 +- src/web/assets/cp/dist/cp.js.map | 2 +- src/web/assets/cp/src/js/BaseElementIndex.js | 5 +++++ src/web/assets/cp/src/js/Tabs.js | 6 +++--- 16 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1525c28293a..7e1f6899835 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Input autofocussing has been reintroduced thorughout the control panel. ([#12921](https://github.com/craftcms/cms/discussions/12921)) - The `|json_encode` Twig filter now calls `craft\helpers\Json::encode()` internally, improving error handling. ([#12919](https://github.com/craftcms/cms/issues/12919)) - Fixed a JavaScript error that occurred when resolving an asset move conflict. ([#12920](https://github.com/craftcms/cms/issues/12920)) - Fixed an error that could occur when rebuilding the project config, if there were any custom source definitions for element types that weren’t Composer-installed. ([#12881](https://github.com/craftcms/cms/issues/12881)) diff --git a/src/fieldlayoutelements/TitleField.php b/src/fieldlayoutelements/TitleField.php index 97040f3fac3..b60fedadae4 100644 --- a/src/fieldlayoutelements/TitleField.php +++ b/src/fieldlayoutelements/TitleField.php @@ -46,7 +46,7 @@ class TitleField extends TextField /** * @inheritdoc */ - public bool $autofocus = false; + public bool $autofocus = true; /** * @inheritdoc diff --git a/src/templates/settings/assets/volumes/_edit.twig b/src/templates/settings/assets/volumes/_edit.twig index f640ac82fc8..9c1e35467ed 100644 --- a/src/templates/settings/assets/volumes/_edit.twig +++ b/src/templates/settings/assets/volumes/_edit.twig @@ -10,6 +10,7 @@ name: 'name', value: volume.name, errors: volume.getErrors('name'), + autofocus: true, required: true, }) }} diff --git a/src/templates/settings/categories/_edit.twig b/src/templates/settings/categories/_edit.twig index a1cd7cba787..dc804d1a1e6 100644 --- a/src/templates/settings/categories/_edit.twig +++ b/src/templates/settings/categories/_edit.twig @@ -21,6 +21,7 @@ name: 'name', value: categoryGroup.name, errors: categoryGroup.getErrors('name'), + autofocus: true, required: true, }) }} diff --git a/src/templates/settings/email/_index.twig b/src/templates/settings/email/_index.twig index 9fdfedca893..a7cc6b0c3d0 100644 --- a/src/templates/settings/email/_index.twig +++ b/src/templates/settings/email/_index.twig @@ -49,6 +49,7 @@ name: 'fromEmail', suggestEnvVars: true, value: settings.fromEmail, + autofocus: true, required: true, errors: (freshSettings ? null : settings.getErrors('fromEmail')) }) }} diff --git a/src/templates/settings/fields/_edit.twig b/src/templates/settings/fields/_edit.twig index 0fa563a6d41..3dcaff3d485 100644 --- a/src/templates/settings/fields/_edit.twig +++ b/src/templates/settings/fields/_edit.twig @@ -47,6 +47,7 @@ value: field.name, errors: field.getErrors('name'), required: true, + autofocus: true }) }} {{ forms.textField({ diff --git a/src/templates/settings/filesystems/_edit.twig b/src/templates/settings/filesystems/_edit.twig index c3eb9ab29c8..0469fe07ae8 100644 --- a/src/templates/settings/filesystems/_edit.twig +++ b/src/templates/settings/filesystems/_edit.twig @@ -9,6 +9,7 @@ name: 'name', value: (filesystem is defined ? filesystem.name : null), errors: (filesystem is defined ? filesystem.getErrors('name') : null), + autofocus: true, required: true, }) }} diff --git a/src/templates/settings/globals/_edit.twig b/src/templates/settings/globals/_edit.twig index 42b062e21f8..adf0fa395da 100644 --- a/src/templates/settings/globals/_edit.twig +++ b/src/templates/settings/globals/_edit.twig @@ -18,6 +18,7 @@ name: 'name', value: globalSet.name, errors: globalSet.getErrors('name'), + autofocus: true, required: true, }) }} diff --git a/src/templates/settings/sections/_edit.twig b/src/templates/settings/sections/_edit.twig index 2bd8c24565a..3d70d36b370 100644 --- a/src/templates/settings/sections/_edit.twig +++ b/src/templates/settings/sections/_edit.twig @@ -38,6 +38,7 @@ name: 'name', value: section.name, errors: section.getErrors('name'), + autofocus: true, required: true, }) }} diff --git a/src/templates/settings/sites/_edit.twig b/src/templates/settings/sites/_edit.twig index 685a9d31dbf..bcf07701a54 100644 --- a/src/templates/settings/sites/_edit.twig +++ b/src/templates/settings/sites/_edit.twig @@ -31,6 +31,7 @@ value: site.getName(false), suggestEnvVars: true, errors: site.getErrors('name'), + autofocus: true, required: true, }) }} diff --git a/src/templates/settings/tags/_edit.twig b/src/templates/settings/tags/_edit.twig index 66e1a2dfbf8..27d3895e4a8 100644 --- a/src/templates/settings/tags/_edit.twig +++ b/src/templates/settings/tags/_edit.twig @@ -18,6 +18,7 @@ name: 'name', value: tagGroup.name, errors: tagGroup.getErrors('name'), + autofocus: true, required: true, }) }} diff --git a/src/templates/users/_accountfields.twig b/src/templates/users/_accountfields.twig index d60588da9f1..3e0de828129 100644 --- a/src/templates/users/_accountfields.twig +++ b/src/templates/users/_accountfields.twig @@ -8,6 +8,7 @@ id: 'username', name: 'username', value: (user is defined ? user.username : null), + autofocus: true, autocomplete: false, autocapitalize: false, disabled: static or (isNewUser or (currentUser.admin or user.getIsCurrent()) ? false : true), diff --git a/src/web/assets/cp/dist/cp.js b/src/web/assets/cp/dist/cp.js index f99c504950c..aef068897bc 100644 --- a/src/web/assets/cp/dist/cp.js +++ b/src/web/assets/cp/dist/cp.js @@ -1,2 +1,2 @@ -(function(){var __webpack_modules__={463:function(){Craft.Accordion=Garnish.Base.extend({$trigger:null,targetSelector:null,_$target:null,init:function(t){var e=this;this.$trigger=$(t),this.$trigger.data("accordion")&&(console.warn("Double-instantiating an accordion trigger on an element"),this.$trigger.data("accordion").destroy()),this.$trigger.data("accordion",this),this.targetSelector=this.$trigger.attr("aria-controls")?"#".concat(this.$trigger.attr("aria-controls")):null,this.targetSelector&&(this._$target=$(this.targetSelector)),this.addListener(this.$trigger,"click","onTriggerClick"),this.addListener(this.$trigger,"keypress",(function(t){var i=t.keyCode;i!==Garnish.SPACE_KEY&&i!==Garnish.RETURN_KEY||(t.preventDefault(),e.onTriggerClick())}))},onTriggerClick:function(){"true"===this.$trigger.attr("aria-expanded")?this.hideTarget(this._$target):this.showTarget(this._$target)},showTarget:function(t){var e=this;if(t&&t.length){this.showTarget._currentHeight=t.height(),t.removeClass("hidden"),this.$trigger.removeClass("collapsed").addClass("expanded").attr("aria-expanded","true");for(var i=0;i .address-card");for(var s=0;s=this.settings.maxItems)){var e=$(t).appendTo(this.$tbody),i=e.find(".delete");this.settings.sortable&&this.sorter.addItems(e),this.$deleteBtns=this.$deleteBtns.add(i),this.addListener(i,"click","handleDeleteBtnClick"),this.totalItems++,this.updateUI()}},reorderItems:function(){var t=this;if(this.settings.sortable){for(var e=[],i=0;i=this.settings.maxItems?$(this.settings.newItemBtnSelector).addClass("hidden"):$(this.settings.newItemBtnSelector).removeClass("hidden"))}},{defaults:{tableSelector:null,noItemsSelector:null,newItemBtnSelector:null,idAttribute:"data-id",nameAttribute:"data-name",sortable:!1,allowDeleteAll:!0,minItems:0,maxItems:null,reorderAction:null,deleteAction:null,reorderSuccessMessage:Craft.t("app","New order saved."),reorderFailMessage:Craft.t("app","Couldn’t save new order."),confirmDeleteMessage:Craft.t("app","Are you sure you want to delete “{name}”?"),deleteSuccessMessage:Craft.t("app","“{name}” deleted."),deleteFailMessage:Craft.t("app","Couldn’t delete “{name}”."),onReorderItems:$.noop,onDeleteItem:$.noop}})},6872:function(){Craft.AssetImageEditor=Garnish.Modal.extend({$body:null,$footer:null,$imageTools:null,$buttons:null,$cancelBtn:null,$replaceBtn:null,$saveBtn:null,$focalPointBtn:null,$editorContainer:null,$straighten:null,$croppingCanvas:null,$spinner:null,$constraintContainer:null,$constraintRadioInputs:null,$customConstraints:null,canvas:null,image:null,viewport:null,focalPoint:null,grid:null,croppingCanvas:null,clipper:null,croppingRectangle:null,cropperHandles:null,cropperGrid:null,croppingShade:null,imageStraightenAngle:0,viewportRotation:0,originalWidth:0,originalHeight:0,imageVerticeCoords:null,zoomRatio:1,animationInProgress:!1,currentView:"",assetId:null,cacheBust:null,draggingCropper:!1,scalingCropper:!1,draggingFocal:!1,previousMouseX:0,previousMouseY:0,shiftKeyHeld:!1,editorHeight:0,editorWidth:0,cropperState:!1,scaleFactor:1,flipData:{},focalPointState:!1,maxImageSize:null,lastLoadedDimensions:null,imageIsLoading:!1,mouseMoveEvent:null,croppingConstraint:!1,constraintOrientation:"landscape",showingCustomConstraint:!1,saving:!1,renderImage:null,renderCropper:null,_queue:null,init:function(t,e){var i=this;this._queue=new Craft.Queue,this.cacheBust=Date.now(),this.setSettings(e,Craft.AssetImageEditor.defaults),null===this.settings.allowDegreeFractions&&(this.settings.allowDegreeFractions=Craft.isImagick),Garnish.prefersReducedMotion()&&(this.settings.animationDuration=1),this.assetId=t,this.flipData={x:0,y:0},this.$container=$('').appendTo(Garnish.$bod),this.$body=$('
').appendTo(this.$container),this.$footer=$('