pull/5216/head
Oliver Günther 8 years ago
parent 7e8dc321fa
commit c15496d6da
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 6
      frontend/app/components/wp-fast-table/builders/rows/editing-row-builder.ts
  2. 2
      frontend/app/components/wp-fast-table/builders/rows/single-row-builder.ts
  3. 2
      frontend/app/components/wp-fast-table/handlers/click-or-enter-handler.ts
  4. 2
      frontend/app/components/wp-table/wp-table.directive.html
  5. 15
      frontend/app/services/keyboard-shortcut-service.js
  6. 21
      spec/features/accessibility/work_packages/work_package_query_spec.rb
  7. 5
      spec/features/work_packages/new_work_package_spec.rb
  8. 4
      spec/features/work_packages/table/edit_work_packages_spec.rb

@ -27,14 +27,10 @@ export class EditingRowBuilder extends SingleRowBuilder {
if (editForm.activeFields[column] && oldTd.length) {
rowElement.appendChild(oldTd[0]);
} else {
let cell = this.cellBuilder.build(row.object, column);
rowElement.appendChild(cell);
this.buildCell(row.object, column, rowElement);
}
});
// Last column: details link
this.detailsLinkBuilder.build(row.object, rowElement);
return rowElement;
}
}

@ -11,7 +11,7 @@ import {rowId} from '../../helpers/wp-table-row-helpers';
export const rowClassName = 'wp-table--row';
export const internalColumnDetails = 'internal:detailsLink';
export const internalColumnDetails = '__internal-detailsLink';
export class SingleRowBuilder {
// Injections

@ -6,13 +6,11 @@ import {WorkPackageTable} from '../wp-fast-table';
* Execute the callback if the given JQuery Event is either an ENTER key or a click
*/
export function onClickOrEnter(evt:JQueryEventObject, callback:() => void) {
console.log("click or enter?");
if (evt.type === 'click' || (evt.type === 'keydown' && evt.which === keyCodes.ENTER)) {
callback();
return false;
}
console.log("NOPE!");
return true;
}

@ -53,7 +53,7 @@
</td>
</tr>
</tbody>
<tbody class="work-package--results-tbody">
<tbody class="results-tbody work-package--results-tbody">
</tbody>
<tbody wp-inline-create
project-identifier="projectIdentifier"

@ -120,15 +120,15 @@ module.exports = function($window, $rootScope, $timeout, PathHelper) {
}
// this could be extracted into a separate component if it grows
var accessibleListSelector = 'table.list, table.keyboard-accessible-list';
var accessibleRowSelector = 'table.list tr, table.keyboard-accessible-list tr';
var accessibleListSelector = 'table.keyboard-accessible-list';
var accessibleRowSelector = 'table.keyboard-accessible-list tbody tr';
function findListInPage() {
var domLists, focusElements;
focusElements = [];
domLists = angular.element(accessibleListSelector);
domLists.find('tbody tr').each(function(index, tr){
var firstLink = angular.element(tr).find(':visible:tabbable:not(.toggle-all, input)')[0];
var firstLink = angular.element(tr).find(':visible:tabbable')[0];
if ( firstLink !== undefined ) { focusElements.push(firstLink); }
});
return focusElements;
@ -137,14 +137,19 @@ module.exports = function($window, $rootScope, $timeout, PathHelper) {
function focusItemOffset(offset) {
var list, index;
list = findListInPage();
if (list === null) { return; }
index = list.indexOf(
angular
.element(document.activeElement)
.parents(accessibleRowSelector)
.find(':visible:tabbable:not(input)')[0]
.closest(accessibleRowSelector)
.find(':visible:tabbable')[0]
);
var target = angular.element(list[(index+offset+list.length) % list.length])
angular.element(list[(index+offset+list.length) % list.length]).focus();
}
function focusNextItem() {

@ -174,24 +174,31 @@ describe 'Work package index accessibility', type: :feature, selenium: true do
FactoryGirl.create(:work_package,
project: project)
}
before do visit_index_page end
before do
visit_index_page
end
context 'focus' do
let(:first_link_selector) do
'table.keyboard-accessible-list tbody tr:first-child a'
"#wp-row-#{yet_another_work_package.id} td.id a"
end
let(:second_link_selector) do
'table.keyboard-accessible-list tbody tr:nth-child(2) a'
"#wp-row-#{another_work_package.id} td.id a"
end
it 'navigates with J' do
it 'navigates with J and K' do
expect(page).to have_selector("#wp-row-#{yet_another_work_package.id}")
expect(page).to have_selector("#wp-row-#{another_work_package.id}")
find('body').native.send_keys('j')
expect(page).to have_focus_on(first_link_selector)
end
it 'navigates with K' do
find('body').native.send_keys('k')
# Avoid sending keys on body since that resets focus
page.driver.browser.switch_to.active_element.send_keys('j')
expect(page).to have_focus_on(second_link_selector)
page.driver.browser.switch_to.active_element.send_keys('k')
expect(page).to have_focus_on(first_link_selector)
end
end

@ -214,6 +214,7 @@ describe 'new work package', js: true do
wp_page.subject_field.set('new work package')
save_work_package!
wp_page.dismiss_notification!
expect(page).to have_selector('.wp--row.-checked')
@ -227,6 +228,10 @@ describe 'new work package', js: true do
table_subject.submit_by_enter
table_subject.expect_state_text new_subject
wp_page.expect_notification(
message: 'Successful update. Click here to open this work package in fullscreen view.'
)
new_wp.reload
expect(new_wp.subject).to eq(new_subject)

@ -92,6 +92,10 @@ describe 'Inline editing work packages', js: true do
subject_field.expect_text('Other subject!')
status_field.expect_text(status2.name)
wp_table.expect_notification(message: 'Successful update')
wp_table.dismiss_notification!
wp_table.expect_no_notification(message: 'Successful update')
work_package.reload
expect(work_package.subject).to eq('Other subject!')
expect(work_package.status.id).to eq(status2.id)

Loading…
Cancel
Save