-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5166 from owncloud/28052021_focus-and-announce-br…
…eadcrumbs Focus breadcrumb on route change
- Loading branch information
Showing
4 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
changelog/unreleased/enhancement-focus-breadcrumb-on-route-change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Enhancement: Focus breadcrumb on route change | ||
|
||
We now focus the current breadcrumb item when navigating to another page | ||
and announce the amount of files and folders in the folder the user | ||
has navigated to. | ||
|
||
https://github.com/owncloud/web/pull/5166 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import last from 'lodash-es/last' | ||
import { mapGetters } from 'vuex' | ||
|
||
export default { | ||
computed: { | ||
...mapGetters('Files', ['activeFilesCount']) | ||
}, | ||
methods: { | ||
accessibleBreadcrumb_focusAndAnnounceBreadcrumb(sameRoute) { | ||
const activeBreadcrumb = last( | ||
document.getElementById('files-breadcrumb').children[0].children | ||
) | ||
const activeBreadcrumbItem = activeBreadcrumb.lastChild | ||
|
||
const itemCount = this.activeFilesCount.files + this.activeFilesCount.folders | ||
const announcement = this.$ngettext( | ||
'This folder contains %{ itemCount } item.', | ||
'This folder contains %{ itemCount } items.', | ||
itemCount | ||
) | ||
|
||
const translatedHint = | ||
this.activeFilesCount.folders > 0 || this.activeFilesCount.files > 0 | ||
? announcement | ||
: this.$gettext('This folder has no content.') | ||
|
||
document.querySelectorAll('.oc-breadcrumb-sr').forEach(el => el.remove()) | ||
|
||
const invisibleHint = document.createElement('p') | ||
invisibleHint.className = 'oc-invisible-sr oc-breadcrumb-sr' | ||
invisibleHint.innerHTML = translatedHint | ||
|
||
activeBreadcrumb.append(invisibleHint) | ||
if (sameRoute) { | ||
activeBreadcrumbItem.focus() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters