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] Add button to skip past the discover doc table #12539

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 src/core_plugins/kibana/public/context/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
sorting="contextApp.state.queryParameters.sort"
columns="contextApp.state.queryParameters.columns"
infinite-scroll="true"
minimum-visible-rows="contextApp.state.rows.all.length"
></doc-table>
</div>
</div>
Expand Down
31 changes: 28 additions & 3 deletions src/core_plugins/kibana/public/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,21 @@ app.directive('discoverApp', function () {
};
});

function discoverController($scope, config, courier, $route, $window, Notifier,
AppState, timefilter, Promise, Private, kbnUrl) {
function discoverController(
$document,
$route,
$scope,
$timeout,
$window,
AppState,
Notifier,
Private,
Promise,
config,
courier,
kbnUrl,
timefilter,
) {

const Vis = Private(VisProvider);
const docTitle = Private(DocTitleProvider);
Expand All @@ -106,6 +119,7 @@ function discoverController($scope, config, courier, $route, $window, Notifier,
$scope.queryDocLinks = documentationLinks.query;
$scope.intervalOptions = Private(AggTypesBucketsIntervalOptionsProvider);
$scope.showInterval = false;
$scope.minimumVisibleRows = 50;

$scope.intervalEnabled = function (interval) {
return interval.val !== 'custom';
Expand Down Expand Up @@ -575,10 +589,21 @@ function discoverController($scope, config, courier, $route, $window, Notifier,
columnActions.moveColumn($scope.state.columns, columnName, newIndex);
};

$scope.toTop = function () {
$scope.scrollToTop = function () {
$window.scrollTo(0, 0);
};

$scope.scrollToBottom = function () {
// delay scrolling to after the rows have been rendered
$timeout(() => {
$document.find('#discoverBottomMarker').focus();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you're opting to use $document instead of $element here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's just a remnant of the fact that the code lived deeper in the directive hierarchy previously. good catch

}, 0);
};

$scope.showAllRows = function () {
$scope.minimumVisibleRows = $scope.hits;
};

let loadingVis;
function setupVisualization() {
// If we're not setting anything up we need to return an empty promise
Expand Down
15 changes: 14 additions & 1 deletion src/core_plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ <h2>Searching</h2>

<!-- result -->
<div class="results" ng-show="resultState === 'ready'">
<button
class="kuiButton kuiButton--basic kuiButton--iconText discover-skip-button"
ng-click="showAllRows(); scrollToBottom()"
>
<span class="kuiButton__inner">
<span aria-hidden="true" class="kuiButton__icon kuiIcon fa-chevron-down"></span>
<span>Skip to bottom</span>
</span>
</button>

<div class="discover-timechart" ng-if="opts.timefield">
<header>
<center class="small">
Expand Down Expand Up @@ -151,17 +161,20 @@ <h2>Searching</h2>
data-shared-item
data-title="{{opts.savedSearch.lastSavedTitle}}"
data-description="{{opts.savedSearch.description}}"
minimum-visible-rows="minimumVisibleRows"
render-counter
on-add-column="addColumn"
on-change-sort-order="setSortOrder"
on-move-column="moveColumn"
on-remove-column="removeColumn"
></doc-table>

<a tabindex="0" id="discoverBottomMarker"></a>

<div ng-if="rows.length == opts.sampleSize" class="discover-table-footer">
These are the first {{opts.sampleSize}} documents matching
your search, refine your search to see others.
<a ng-click="toTop()">Back to top.</a>
<a tabindex="0" ng-click="scrollToTop()">Back to top.</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're in here anyway, would you mind adding kbnAccessibleClick to this element? Currently if it has focus and you hit enter, nothing happens.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing that will also mean you can remove tabindex="0".

</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/core_plugins/kibana/public/discover/styles/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,19 @@ disc-field-chooser {
width: auto;
}
}

.discover-skip-button {
position: absolute;
left: -10000px;
top: 4px;
width: 1px;
height: 1px;
overflow: hidden;

&:focus {
left: initial;
right: 15px;
width: auto;
height: auto;
}
}
7 changes: 6 additions & 1 deletion src/ui/public/doc_table/doc_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ uiModules.get('kibana')
infiniteScroll: '=?',
filter: '=?',
filters: '=?',
minimumVisibleRows: '=?',
onAddColumn: '=?',
onChangeSortOrder: '=?',
onMoveColumn: '=?',
onRemoveColumn: '=?',
},
link: function ($scope, $el) {
const notify = new Notifier();
$scope.limit = 50;

$scope.$watch('minimumVisibleRows', (minimumVisibleRows) => {
$scope.limit = Math.max(minimumVisibleRows || 50, $scope.limit || 50);
});

$scope.persist = {
sorting: $scope.sorting,
columns: $scope.columns
Expand Down