@samitouri / QOS-React-2 / commits / d7f6dd5a80

[react-interactions] Fix typo in FocusTable (#16860)

Dominic Gannaway committed Sep 23, 2019 at 14:20 UTC d7f6dd5a80827aea76fc42f07c77d05abb7180b2
2 files changed +19 -19
packages/react-interactions/accessibility/src/FocusTable.js
+4 -4
@@ -149,7 +149,7 @@ export function createFocusTable(): Array<React.Component> {
149 onKeyDown(event: KeyboardEvent): void {
150 const currentCell = scopeRef.current;
151 switch (event.key) {
152 - case 'UpArrow': {
152 + case 'ArrowUp': {
153 const [cells, rowIndex] = getRowCells(currentCell);
154 if (cells !== null) {
155 const [columns, columnIndex] = getRows(currentCell);
@@ -164,7 +164,7 @@ export function createFocusTable(): Array<React.Component> {
164 }
165 return;
166 }
167 - case 'DownArrow': {
167 + case 'ArrowDown': {
168 const [cells, rowIndex] = getRowCells(currentCell);
169 if (cells !== null) {
170 const [columns, columnIndex] = getRows(currentCell);
@@ -181,7 +181,7 @@ export function createFocusTable(): Array<React.Component> {
181 }
182 return;
183 }
184 - case 'LeftArrow': {
184 + case 'ArrowLeft': {
185 const [cells, rowIndex] = getRowCells(currentCell);
186 if (cells !== null) {
187 if (rowIndex > 0) {
@@ -192,7 +192,7 @@ export function createFocusTable(): Array<React.Component> {
192 }
193 return;
194 }
195 - case 'RightArrow': {
195 + case 'ArrowRight': {
196 const [cells, rowIndex] = getRowCells(currentCell);
197 if (cells !== null) {
198 if (rowIndex !== -1) {
packages/react-interactions/accessibility/src/__tests__/FocusTable-test.internal.js
+15 -15
@@ -116,35 +116,35 @@ describe('ReactFocusTable', () => {
116 const a1 = createEventTarget(buttons[0]);
117 a1.focus();
118 a1.keydown({
119 - key: 'RightArrow',
119 + key: 'ArrowRight',
120 });
121 expect(document.activeElement.textContent).toBe('A2');
122
123 const a2 = createEventTarget(document.activeElement);
124 a2.keydown({
125 - key: 'DownArrow',
125 + key: 'ArrowDown',
126 });
127 expect(document.activeElement.textContent).toBe('B2');
128
129 const b2 = createEventTarget(document.activeElement);
130 b2.keydown({
131 - key: 'LeftArrow',
131 + key: 'ArrowLeft',
132 });
133 expect(document.activeElement.textContent).toBe('B1');
134
135 const b1 = createEventTarget(document.activeElement);
136 b1.keydown({
137 - key: 'DownArrow',
137 + key: 'ArrowDown',
138 });
139 expect(document.activeElement.textContent).toBe('C1');
140
141 const c1 = createEventTarget(document.activeElement);
142 c1.keydown({
143 - key: 'DownArrow',
143 + key: 'ArrowDown',
144 });
145 expect(document.activeElement.textContent).toBe('C1');
146 c1.keydown({
147 - key: 'UpArrow',
147 + key: 'ArrowUp',
148 });
149 expect(document.activeElement.textContent).toBe('B1');
150 });
@@ -201,55 +201,55 @@ describe('ReactFocusTable', () => {
201 let a1 = createEventTarget(buttons[0]);
202 a1.focus();
203 a1.keydown({
204 - key: 'RightArrow',
204 + key: 'ArrowRight',
205 });
206 expect(document.activeElement.textContent).toBe('A2');
207
208 let a2 = createEventTarget(document.activeElement);
209 a2.keydown({
210 - key: 'RightArrow',
210 + key: 'ArrowRight',
211 });
212 expect(document.activeElement.textContent).toBe('A3');
213
214 let a3 = createEventTarget(document.activeElement);
215 a3.keydown({
216 - key: 'RightArrow',
216 + key: 'ArrowRight',
217 });
218 expect(document.activeElement.textContent).toBe('A1');
219
220 a1 = createEventTarget(document.activeElement);
221 a1.keydown({
222 - key: 'RightArrow',
222 + key: 'ArrowRight',
223 });
224 expect(document.activeElement.textContent).toBe('A2');
225
226 a2 = createEventTarget(document.activeElement);
227 a2.keydown({
228 - key: 'RightArrow',
228 + key: 'ArrowRight',
229 });
230 expect(document.activeElement.textContent).toBe('A3');
231
232 a3 = createEventTarget(document.activeElement);
233 a3.keydown({
234 - key: 'RightArrow',
234 + key: 'ArrowRight',
235 });
236 expect(document.activeElement.textContent).toBe('A1');
237
238 a1 = createEventTarget(document.activeElement);
239 a1.keydown({
240 - key: 'RightArrow',
240 + key: 'ArrowRight',
241 });
242 expect(document.activeElement.textContent).toBe('A2');
243
244 a2 = createEventTarget(document.activeElement);
245 a2.keydown({
246 - key: 'RightArrow',
246 + key: 'ArrowRight',
247 });
248 expect(document.activeElement.textContent).toBe('A3');
249
250 a3 = createEventTarget(document.activeElement);
251 a3.keydown({
252 - key: 'RightArrow',
252 + key: 'ArrowRight',
253 });
254 expect(document.activeElement.textContent).toBe('A3');
255 });