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

Remove sidebar from focus order when closed from expanded view #15332

Merged
merged 5 commits into from
Jul 11, 2024
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.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fixed a bug where structures’ Max Levels settings weren’t being enforced when dragging elements with collapsed descendants. ([#15310](https://github.com/craftcms/cms/issues/15310))
- Fixed a bug where `craft\helpers\ElementHelper::isDraft()`, `isRevision()`, and `isDraftOrRevision()` weren’t returning `true` if a nested draft/revision element was passed in, but the root element was canonical. ([#15303](https://github.com/craftcms/cms/issues/15303))
- Fixed a bug where focus could be trapped within slideout sidebars. ([#15314](https://github.com/craftcms/cms/issues/15314))
- Fixed a bug where element slideout sidebars were included in the focus order when hidden. ([#15332](https://github.com/craftcms/cms/pull/15332))
- Fixed a bug where field status indicators weren’t visible on mobile viewports.
- Fixed a bug where sorting elements by custom field within element indexes wasn’t always working. ([#15297](https://github.com/craftcms/cms/issues/15297))
- Fixed a bug where asset bulk element actions were available when folders were selected. ([#15301](https://github.com/craftcms/cms/issues/15301))
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.

18 changes: 16 additions & 2 deletions src/web/assets/cp/src/js/CpScreenSlideout.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,19 @@ Craft.CpScreenSlideout = Craft.Slideout.extend(
ignoreFailedRequest: false,
fieldsWithErrors: null,

/**
* @returns {boolean} Whether the slideout is wide enough to show the sidebar alongside the content
*/
get showExpandedView() {
return this.$container.width() > 700;
},

get sidebarIsOverlapping() {
return (
this.showingSidebar && this.$sidebar.css('position') === 'absolute'
);
},

init: function (action, settings) {
this.action = action;
this.setSettings(settings, Craft.CpScreenSlideout.defaults);
Expand Down Expand Up @@ -347,7 +356,6 @@ Craft.CpScreenSlideout = Craft.Slideout.extend(

this.hasSidebar = true;

// is the slideout wide enough to show it alongside the content?
if (this.showExpandedView) {
this.showSidebar();
} else {
Expand Down Expand Up @@ -468,6 +476,12 @@ Craft.CpScreenSlideout = Craft.Slideout.extend(
this.$container.removeClass('showing-sidebar');
this.$body.removeClass('no-scroll');

// Do the same thing when there are no transitions
if (!this.sidebarIsOverlapping) {
this.$sidebar.addClass('hidden');
this.$sidebarBtn.focus();
}

this.$sidebar
.off('transitionend.so')
.css(this._closedSidebarStyles())
Expand All @@ -488,7 +502,7 @@ Craft.CpScreenSlideout = Craft.Slideout.extend(
},

hideSidebarIfOverlapping() {
if (this.showingSidebar && this.$sidebar.css('position') === 'absolute') {
if (this.sidebarIsOverlapping) {
this.hideSidebar();
return true;
} else {
Expand Down