Skip to content

Commit 53492f9

Browse files
authored
Merge pull request #60949 from nextcloud/backport/60897/stable34
2 parents 8a84c44 + 8d5cfb3 commit 53492f9

4 files changed

Lines changed: 44 additions & 25 deletions

File tree

core/src/components/AppMenu.vue

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
<img
5858
class="app-menu__current-app-icon"
5959
:class="{ 'app-menu__current-app-icon--settings': currentApp.type === 'settings' }"
60-
:src="currentApp.icon"
60+
:src="displayIcon"
6161
alt=""
6262
aria-hidden="true">
6363
</template>
6464
<span class="app-menu__current-app-name">
65-
{{ currentApp.name }}
65+
{{ displayName }}
6666
</span>
6767
</NcButton>
6868
</nav>
@@ -160,11 +160,34 @@ export default defineComponent({
160160
?? Object.values(this.settingsList).find((entry) => entry.active && !SETTINGS_ACTION_IDS.has(entry.id))
161161
},
162162
163-
// aria-label overrides the inner span text, so the section name
163+
// Trigger label. Settings sub-section names ("Personal info",
164+
// "Appearance and accessibility", ...) are too long and varied to
165+
// surface in the header; collapse them all to a single "Settings".
166+
displayName(): string {
167+
if (!this.currentApp) {
168+
return ''
169+
}
170+
return this.currentApp.type === 'settings'
171+
? t('core', 'Settings')
172+
: this.currentApp.name
173+
},
174+
175+
// Match the collapsed label: a generic cog for any settings
176+
// sub-section instead of the per-section icon.
177+
displayIcon(): string {
178+
if (!this.currentApp) {
179+
return ''
180+
}
181+
return this.currentApp.type === 'settings'
182+
? imagePath('core', 'actions/settings.svg')
183+
: this.currentApp.icon
184+
},
185+
186+
// aria-label overrides the inner span text, so the displayed name
164187
// has to be duplicated here for screen readers.
165188
currentAppLabel(): string {
166189
return this.currentApp
167-
? t('core', 'Open apps menu, currently in {app}', { app: this.currentApp.name })
190+
? t('core', 'Open apps menu, currently in {app}', { app: this.displayName })
168191
: t('core', 'Open apps menu')
169192
},
170193
@@ -452,23 +475,18 @@ export default defineComponent({
452475
}
453476
454477
&__current-app-name {
455-
// Hidden by default so the icon-only trigger fits alongside the
456-
// centered search input. The button's aria-label still announces the
457-
// section name. At wide viewports we restore the label with a
458-
// truncation cap as a safety net for long localized names.
459-
display: none;
460-
461-
@media only screen and (min-width: 1400px) {
462-
display: inline-block;
463-
vertical-align: middle;
464-
font-size: var(--default-font-size);
465-
font-weight: 500;
466-
white-space: nowrap;
467-
letter-spacing: -0.5px;
468-
overflow: hidden;
469-
text-overflow: ellipsis;
470-
max-width: clamp(160px, 18vw, 360px);
471-
}
478+
// inline-block: inline elements ignore max-width + overflow.
479+
display: inline-block;
480+
vertical-align: middle;
481+
font-size: var(--default-font-size);
482+
font-weight: 500;
483+
white-space: nowrap;
484+
letter-spacing: -0.5px;
485+
overflow: hidden;
486+
text-overflow: ellipsis;
487+
// Cap width so long localized labels ellipsize instead of pushing
488+
// the header icons off-screen (.header-start doesn't shrink).
489+
max-width: clamp(80px, 22vw, 320px);
472490
}
473491
474492
&__popover {

core/src/tests/components/AppMenu.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ describe('core: AppMenu', () => {
191191
})
192192
const wrapper = mount(AppMenu, { attachTo: document.body })
193193
expect(wrapper.find('.app-menu__current-app').exists()).toBe(true)
194-
expect(wrapper.find('.app-menu__current-app-name').text()).toBe('Administration settings')
194+
// Settings sub-section names are collapsed to a single "Settings" label.
195+
expect(wrapper.find('.app-menu__current-app-name').text()).toBe('Settings')
195196
})
196197

197198
it('prefers the active app over a settings entry when both are marked active', () => {

dist/core-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)