Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pagination focus #11565

Merged
merged 4 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Added `craft\web\Controller::getCurrentUser()`. ([#11754](https://github.com/craftcms/cms/pull/11754))

### Changed
- Improved the control panel accessibility. ([#11565](https://github.com/craftcms/cms/pull/11565))
- `users/session-info` responses now include a `csrfTokenName` key. ([#11706](https://github.com/craftcms/cms/pull/11706))
- `craft\services\Search::EVENT_BEFORE_INDEX_KEYWORDS` is now cancellable by setting `$event->isValid` to `false`. ([#11705](https://github.com/craftcms/cms/discussions/11705))
- `checkboxSelect` inputs without `showAllOption: true` now post an empty value if no options were selected. ([#11748](https://github.com/craftcms/cms/issues/11748))
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.

11 changes: 8 additions & 3 deletions src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
return params;
},

updateElements: function (preservePagination) {
updateElements: function (preservePagination, pageChanged) {
// Ignore if we're not fully initialized yet
if (!this.initialized) {
return;
Expand Down Expand Up @@ -836,6 +836,11 @@ Craft.BaseElementIndex = Garnish.Base.extend(
: this.$main
).scrollTop(0);
this._updateView(params, response.data);

if (pageChanged) {
const $elementContainer = this.view.getElementContainer();
Garnish.firstFocusableElement($elementContainer).trigger('focus');
}
})
.catch((e) => {
this.setIndexAvailable();
Expand Down Expand Up @@ -1979,7 +1984,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
this.removeListener($prevBtn, 'click');
this.removeListener($nextBtn, 'click');
this.setPage(this.page - 1);
this.updateElements(true);
this.updateElements(true, true);
});
}

Expand All @@ -1988,7 +1993,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
this.removeListener($prevBtn, 'click');
this.removeListener($nextBtn, 'click');
this.setPage(this.page + 1);
this.updateElements(true);
this.updateElements(true, true);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/garnish/dist/garnish.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/web/assets/garnish/src/Garnish.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ Garnish = $.extend(Garnish, {
return $(container).find(':focus').length > 0;
},

/**
* Gets the first focusable element inside a container
* @param {Object} container
*/
firstFocusableElement: function (container) {
return $(container).find(':focusable').first();
},

/**
* Traps focus within a container, so when focus is tabbed out of it, it’s cycled back into it.
* @param {Object} container
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/pluginstore/dist/js/app.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.