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

Accessibility: Adding label fors and control ids for the macro picker #10101

Merged
merged 17 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3a031e8
Merge pull request #1 from umbraco/v8/contrib
RachBreeze Aug 22, 2020
c708b37
Merge branch 'v8/contrib' of https://github.com/RachBreeze/Umbraco-CM…
Oct 7, 2020
0b49cd0
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Oct 22, 2020
e395a42
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Oct 25, 2020
d988bc6
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Oct 26, 2020
35b9897
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Oct 31, 2020
81d9665
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Nov 19, 2020
5d2e0b5
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Dec 17, 2020
251ea27
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Jan 4, 2021
1186f1b
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Jan 18, 2021
0bade7d
Added support for screeen reader alerts on the embed so that assitive…
Jan 31, 2021
4a8735d
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Feb 13, 2021
f90fb99
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Feb 28, 2021
aec2a86
Merge branch 'v8/contrib' of https://github.com/umbraco/Umbraco-CMS i…
Apr 4, 2021
d5404e2
Added support for label fors for the macro picker and also gave the ,…
Apr 4, 2021
764587f
Now displays a count of the matching macros returned. Please note the…
Apr 5, 2021
bb59dff
Removed src-only class for the display of the count of messages
Apr 8, 2021
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
function MacroPickerController($scope, entityResource, macroResource, umbPropEditorHelper, macroService, formHelper, localizationService) {

$scope.macros = [];
$scope.a11yInfo = "";
$scope.model.selectedMacro = null;
$scope.model.macroParams = [];

$scope.displayA11YMessageForFilter = displayA11YMessageForFilter;
$scope.wizardStep = "macroSelect";
$scope.noMacroParams = false;

$scope.model.searchTerm = "";
function onInit() {
if (!$scope.model.title) {
localizationService.localize("defaultdialogs_selectMacro").then(function (value) {
Expand Down Expand Up @@ -49,6 +50,7 @@ function MacroPickerController($scope, entityResource, macroResource, umbPropEdi
$scope.model.submit($scope.model);
} else {
$scope.wizardStep = 'macroSelect';
displayA11yMessages($scope.macros);
}

} else {
Expand Down Expand Up @@ -95,6 +97,28 @@ function MacroPickerController($scope, entityResource, macroResource, umbPropEdi
});
}

function displayA11yMessages(macros) {
if ($scope.noMacroParams || !macros || macros.length === 0)
localizationService.localize("general_searchNoResult").then(function (value) {
$scope.a11yInfo = value;
});
else if (macros) {
if (macros.length === 1) {
localizationService.localize("treeSearch_searchResult").then(function(value) {
$scope.a11yInfo = "1 " + value;
});
} else {
localizationService.localize("treeSearch_searchResults").then(function (value) {
$scope.a11yInfo = macros.length + " " + value;
});
}
}
}

function displayA11YMessageForFilter() {
var macros = _.filter($scope.macros, v => v.name.toLowerCase().includes($scope.model.searchTerm.toLowerCase()));
displayA11yMessages(macros);
}
//here we check to see if we've been passed a selected macro and if so we'll set the
//editor to start with parameter editing
if ($scope.model.dialogData && $scope.model.dialogData.macroData) {
Expand Down Expand Up @@ -141,10 +165,11 @@ function MacroPickerController($scope, entityResource, macroResource, umbPropEdi
//we don't have a pre-selected macro so ensure the correct step is set
$scope.wizardStep = 'macroSelect';
}
displayA11yMessages($scope.macros);
});

onInit();

}

angular.module("umbraco").controller("Umbraco.Overlays.MacroPickerController", MacroPickerController);
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
<div ng-switch="wizardStep">

<div ng-switch-when="macroSelect" class="macro-select">

<umb-search-filter
input-id="macro-search"
model="searchTerm"
label-key="placeholders_filter"
text="Type to filter..."
css-class="w-100 mb-15"
auto-focus="true">
<label for="macro-search" class="sr-only">{{model.title}}</label>
<umb-search-filter input-id="macro-search"
model="model.searchTerm"
label-key="placeholders_filter"
text="Type to filter..."
css-class="w-100 mb-15"
on-change="displayA11YMessageForFilter()"
auto-focus="true">
</umb-search-filter>

<p ng-bind="a11yInfo" class="sr-only" role="alert"></p>
<ul class="umb-card-grid -three-in-row">
<li ng-repeat="availableItem in macros | orderBy:'name' | filter:searchTerm">
<li ng-repeat="availableItem in macros | orderBy:'name' | filter:model.searchTerm">
<button class="btn-reset umb-card-grid-item" title="{{availableItem.name}}" ng-click="selectMacro(availableItem)">
<span>
<i class="icon-settings-alt" aria-hidden="true"></i>
Expand All @@ -38,7 +38,7 @@
</ul>

<umb-empty-state ng-if="nomacros"
position="center">
position="center">
<localize key="defaultdialogs_noMacros">
There are no macros available to insert
</localize>
Expand All @@ -53,7 +53,7 @@ <h5>{{model.selectedMacro.name}}</h5>
<li ng-repeat="param in model.macroParams">

<ng-form name="parameterForm">
<umb-control-group label="{{param.name}}">
<umb-control-group label="{{param.name}}" alias="{{param.alias}}">
<umb-property-editor model="param"></umb-property-editor>
</umb-control-group>
</ng-form>
Expand Down
4 changes: 4 additions & 0 deletions src/Umbraco.Web.UI/Umbraco/config/lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2576,4 +2576,8 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="viewPublishedContentAcceptButton">View published version</key>
<key alias="viewPublishedContentDeclineButton">Stay in preview mode</key>
</area>
<area alias="treeSearch">
<key alias="searchResult">item returned</key>
<key alias="searchResults">items returned</key>
</area>
</language>
4 changes: 4 additions & 0 deletions src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2595,4 +2595,8 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="viewPublishedContentAcceptButton">View published version</key>
<key alias="viewPublishedContentDeclineButton">Stay in preview mode</key>
</area>
<area alias="treeSearch">
<key alias="searchResult">item returned</key>
<key alias="searchResults">items returned</key>
</area>
</language>