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

Changes to source navigation and element index UI, user-related document titles #14946

Merged
merged 15 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes for Craft CMS 5

## Unreleased

### Accessibility
- On the mobile element index layout, the sidebar is kept open on source selection to prevent focus from being dropped (PT-1303)
- User page document titles have been updated to describe the page purpose (PT-1701)

## 5.1.1 - 2024-05-02

- Fixed a bug where disclosure menus weren’t releasing their `scroll` and `resize` event listeners on hide. ([#14911](https://github.com/craftcms/cms/pull/14911), [#14510](https://github.com/craftcms/cms/issues/14510))
Expand Down
10 changes: 9 additions & 1 deletion src/controllers/EditUserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,19 @@ protected function asEditUserScreen(User $user, string $screen): Response
throw new ForbiddenHttpException('User not authorized to perform this action.');
}

$pageName = $screens[$screen]["label"];
$response = $this->asCpScreen();
if ($user->getIsCurrent()) {
$response->title(Craft::t('app', 'My Account'));
$response->docTitle($pageName);
} else {
$response->title($user->getUiLabel());
$username = $user->getUiLabel();
$extendedTitle = Craft::t('app', 'User {page}', [
'page' => $pageName,
]);
$docTitle = "$username - $extendedTitle";
$response->title($username);
$response->docTitle($docTitle);
}

$navItems = [];
Expand Down
4 changes: 2 additions & 2 deletions src/templates/_layouts/cp.twig
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ history.replaceState(undefined, undefined, window.location.href.match(/^[^#]*/)[
<div id="page-title" class="flex{% if toolbar %} has-toolbar{% endif %}">
{% block pageTitle %}
{% if title is defined and title|length %}
<h1 class="screen-title" title="{{ title }}">{{ title }}</h1>
<h1 class="screen-title" title="{{ title }}">{{ title }}<span id="content-heading"></span></h1>
{% endif %}
{% endblock %}
</div>
Expand Down Expand Up @@ -262,7 +262,7 @@ history.replaceState(undefined, undefined, window.location.href.match(/^[^#]*/)[
aria-controls="sidebar-container"
aria-expanded="false"
>
<span id="content-heading"></span>
{{ 'Show sidebar'|t('app') }}
</button>
</div>
<div id="sidebar-container">
Expand Down
1 change: 1 addition & 0 deletions src/translations/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,7 @@
'User Group' => 'User Group',
'User Groups' => 'User Groups',
'User Permissions' => 'User Permissions',
'User {page}' => 'User {page}',
'User Photo Location' => 'User Photo Location',
'User Photo Volume' => 'User Photo Volume',
'User Photos' => 'User Photos',
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/admintable/dist/js/app.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions src/web/assets/cp/src/css/_cp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,21 @@ li.breadcrumb-toggle-wrapper {
}
}

#content-heading {
font-size: 0.875rem;
font-weight: normal;

&:before {
content: '/';
display: inline-block;
margin-inline: 0.5rem;
}

@media only screen and (min-width: $minHorizontalUiWidth) {
display: none;
}
}

#toolbar {
flex: 1;
align-items: flex-start;
Expand Down Expand Up @@ -1232,8 +1247,7 @@ li.breadcrumb-toggle-wrapper {
// Rearrange #main-content to flow vertically at < 999
@media only screen and (max-width: $minHorizontalUiWidth - calc(1rem/16)) {
#header {
display: flex;
flex-wrap: wrap;
display: block;

.flex:not(#toolbar) {
margin-top: 10px;
Expand All @@ -1242,19 +1256,12 @@ li.breadcrumb-toggle-wrapper {

#toolbar {
flex-wrap: wrap !important;
order: 3;
width: 100%;
flex: auto;

& > * {
margin-top: 10px !important;
}
}

#action-buttons {
order: 2;
}

body.fixed-header #header .flex:first-child {
margin-top: 0;
}
Expand Down
9 changes: 8 additions & 1 deletion src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ Craft.BaseElementIndex = Garnish.Base.extend(
}
this.afterSetInitialSource(queryParams);
}

// Set visible source name on small/zoomed screens
this.updateMainHeading();
},

afterInit: function () {
Expand Down Expand Up @@ -772,6 +775,10 @@ Craft.BaseElementIndex = Garnish.Base.extend(
}
},

updateMainHeading: function () {
$('#content-heading').text(this.getSourceLabel());
},

deinitSource: function ($source) {
this.sourceNav.removeItems($source);
this.deinitSourceToggle($source);
Expand Down Expand Up @@ -2162,7 +2169,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
this.setInstanceState('selectedSource', this.sourceKey);
this.sourceNav.selectItem($source);

Craft.cp.updateContentHeading();
this.updateMainHeading();

if (this.searching) {
// Clear the search value without causing it to update elements
Expand Down
13 changes: 1 addition & 12 deletions src/web/assets/cp/src/js/CP.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Craft.CP = Garnish.Base.extend(

this.isMobile = Garnish.isMobileBrowser();

this.updateContentHeading();
//this.updateContentHeading();

// Swap any instruction text with info icons
let $allInstructions = this.$details.find(
Expand Down Expand Up @@ -480,17 +480,6 @@ Craft.CP = Garnish.Base.extend(
Craft.submitForm(this.$primaryForm, options);
},

updateSidebarMenuLabel: function () {
this.updateContentHeading();
},

updateContentHeading: function () {
const $item = this.$sidebar.find('a.sel:first');
const $label = $item.children('.label');
$('#content-heading').text($label.length ? $label.text() : $item.text());
Garnish.$bod.removeClass('showing-sidebar');
},

toggleNav: function () {
const isExpanded = this.navIsExpanded();

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.