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

[react-interactions] Fix typo in FocusTable #16860

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions packages/react-interactions/accessibility/src/FocusTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function createFocusTable(): Array<React.Component> {
onKeyDown(event: KeyboardEvent): void {
const currentCell = scopeRef.current;
switch (event.key) {
case 'UpArrow': {
case 'ArrowUp': {
const [cells, rowIndex] = getRowCells(currentCell);
if (cells !== null) {
const [columns, columnIndex] = getRows(currentCell);
Expand All @@ -164,7 +164,7 @@ export function createFocusTable(): Array<React.Component> {
}
return;
}
case 'DownArrow': {
case 'ArrowDown': {
const [cells, rowIndex] = getRowCells(currentCell);
if (cells !== null) {
const [columns, columnIndex] = getRows(currentCell);
Expand All @@ -181,7 +181,7 @@ export function createFocusTable(): Array<React.Component> {
}
return;
}
case 'LeftArrow': {
case 'ArrowLeft': {
const [cells, rowIndex] = getRowCells(currentCell);
if (cells !== null) {
if (rowIndex > 0) {
Expand All @@ -192,7 +192,7 @@ export function createFocusTable(): Array<React.Component> {
}
return;
}
case 'RightArrow': {
case 'ArrowRight': {
const [cells, rowIndex] = getRowCells(currentCell);
if (cells !== null) {
if (rowIndex !== -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,35 +116,35 @@ describe('ReactFocusTable', () => {
const a1 = createEventTarget(buttons[0]);
a1.focus();
a1.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A2');

const a2 = createEventTarget(document.activeElement);
a2.keydown({
key: 'DownArrow',
key: 'ArrowDown',
});
expect(document.activeElement.textContent).toBe('B2');

const b2 = createEventTarget(document.activeElement);
b2.keydown({
key: 'LeftArrow',
key: 'ArrowLeft',
});
expect(document.activeElement.textContent).toBe('B1');

const b1 = createEventTarget(document.activeElement);
b1.keydown({
key: 'DownArrow',
key: 'ArrowDown',
});
expect(document.activeElement.textContent).toBe('C1');

const c1 = createEventTarget(document.activeElement);
c1.keydown({
key: 'DownArrow',
key: 'ArrowDown',
});
expect(document.activeElement.textContent).toBe('C1');
c1.keydown({
key: 'UpArrow',
key: 'ArrowUp',
});
expect(document.activeElement.textContent).toBe('B1');
});
Expand Down Expand Up @@ -201,55 +201,55 @@ describe('ReactFocusTable', () => {
let a1 = createEventTarget(buttons[0]);
a1.focus();
a1.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A2');

let a2 = createEventTarget(document.activeElement);
a2.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A3');

let a3 = createEventTarget(document.activeElement);
a3.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A1');

a1 = createEventTarget(document.activeElement);
a1.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A2');

a2 = createEventTarget(document.activeElement);
a2.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A3');

a3 = createEventTarget(document.activeElement);
a3.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A1');

a1 = createEventTarget(document.activeElement);
a1.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A2');

a2 = createEventTarget(document.activeElement);
a2.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A3');

a3 = createEventTarget(document.activeElement);
a3.keydown({
key: 'RightArrow',
key: 'ArrowRight',
});
expect(document.activeElement.textContent).toBe('A3');
});
Expand Down