Skip to content

Commit

Permalink
Reintroduce autofocus for now
Browse files Browse the repository at this point in the history
Reverts #12332
Reverts #12406
Resolves #12921
  • Loading branch information
brandonkelly committed Mar 17, 2023
1 parent 8b51452 commit 81a217e
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/fieldlayoutelements/TitleField.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TitleField extends TextField
/**
* @inheritdoc
*/
public bool $autofocus = false;
public bool $autofocus = true;

/**
* @inheritdoc
Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/assets/volumes/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
name: 'name',
value: volume.name,
errors: volume.getErrors('name'),
autofocus: true,
required: true,
}) }}

Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/categories/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
name: 'name',
value: categoryGroup.name,
errors: categoryGroup.getErrors('name'),
autofocus: true,
required: true,
}) }}

Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/email/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
name: 'fromEmail',
suggestEnvVars: true,
value: settings.fromEmail,
autofocus: true,
required: true,
errors: (freshSettings ? null : settings.getErrors('fromEmail'))
}) }}
Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/fields/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
value: field.name,
errors: field.getErrors('name'),
required: true,
autofocus: true
}) }}

{{ forms.textField({
Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/filesystems/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}) }}

Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/globals/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
name: 'name',
value: globalSet.name,
errors: globalSet.getErrors('name'),
autofocus: true,
required: true,
}) }}

Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/sections/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
name: 'name',
value: section.name,
errors: section.getErrors('name'),
autofocus: true,
required: true,
}) }}

Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/sites/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
value: site.getName(false),
suggestEnvVars: true,
errors: site.getErrors('name'),
autofocus: true,
required: true,
}) }}

Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/tags/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
name: 'name',
value: tagGroup.name,
errors: tagGroup.getErrors('name'),
autofocus: true,
required: true,
}) }}

Expand Down
1 change: 1 addition & 0 deletions src/templates/users/_accountfields.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ Craft.BaseElementIndex = Garnish.Base.extend(
}
});

// Auto-focus the Search box
if (!Garnish.isMobileBrowser(true)) {
this.$search.trigger('focus');
}

// View menus
this.viewMenus = {};

Expand Down
6 changes: 3 additions & 3 deletions src/web/assets/cp/src/js/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Craft.Tabs = Garnish.Base.extend({
this.addListener($a, 'keydown', (ev) => {
if ([Garnish.SPACE_KEY, Garnish.RETURN_KEY].includes(ev.keyCode)) {
ev.preventDefault();
this.selectTab(ev.currentTarget, true);
this.selectTab(ev.currentTarget);
}
});
this.addListener($a, 'click', (ev) => {
ev.preventDefault();
this.selectTab(ev.currentTarget, true);
this.selectTab(ev.currentTarget);
});
}

Expand Down Expand Up @@ -108,7 +108,7 @@ Craft.Tabs = Garnish.Base.extend({
});
},

selectTab: function (tab, focusTab = false) {
selectTab: function (tab, focusTab = true) {
const $tab = this._getTab(tab);

if ($tab[0] === this.$selectedTab[0]) {
Expand Down

0 comments on commit 81a217e

Please sign in to comment.