Skip to content

Commit 419044a

Browse files
committed
Clean up the interface and adjust callers
1 parent 3a1aa75 commit 419044a

File tree

10 files changed

+60
-71
lines changed

10 files changed

+60
-71
lines changed

apps/web/src/accessibility/RovingTabIndex.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@ import React from "react";
1010
import {
1111
checkInputableElement,
1212
findSiblingElement,
13-
reducer,
1413
RovingAction,
14+
RovingTabIndexActionType,
1515
RovingTabIndexContext,
1616
RovingTabIndexProvider as SharedRovingTabIndexProvider,
17-
Type,
1817
useRovingTabIndex,
1918
type IAction,
20-
type IContext,
2119
type IState,
2220
type RovingTabIndexProviderProps,
2321
} from "@element-hq/web-shared-components";
2422

2523
import { getKeyBindingsManager } from "../KeyBindingsManager";
2624
import { KeyBindingAction } from "./KeyboardShortcuts";
2725

28-
export { checkInputableElement, findSiblingElement, reducer, RovingTabIndexContext, Type, useRovingTabIndex };
29-
export type { IAction, IContext, IState };
26+
export {
27+
checkInputableElement,
28+
findSiblingElement,
29+
RovingTabIndexActionType,
30+
RovingTabIndexContext,
31+
useRovingTabIndex,
32+
};
33+
export type { IAction, IState };
3034

3135
/**
3236
* Module to simplify implementing the Roving TabIndex accessibility technique

apps/web/src/accessibility/roving/types.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/web/src/components/views/dialogs/ForwardDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ import { RoomContextDetails } from "../rooms/RoomContextDetails";
5050
import { filterBoolean } from "../../../utils/arrays";
5151
import {
5252
type IState,
53+
RovingTabIndexActionType,
5354
RovingTabIndexContext,
5455
RovingTabIndexProvider,
55-
Type,
5656
useRovingTabIndex,
5757
} from "../../../accessibility/RovingTabIndex";
5858
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
@@ -368,7 +368,7 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
368368
const node = context.state.nodes[0];
369369
if (node) {
370370
context.dispatch({
371-
type: Type.SetFocus,
371+
type: RovingTabIndexActionType.SetFocus,
372372
payload: { node },
373373
});
374374
node?.scrollIntoView?.({

apps/web/src/components/views/dialogs/spotlight/SpotlightDialog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ import {
4545
import { KeyBindingAction } from "../../../../accessibility/KeyboardShortcuts";
4646
import {
4747
findSiblingElement,
48+
RovingTabIndexActionType,
4849
RovingTabIndexContext,
4950
RovingTabIndexProvider,
50-
Type,
5151
} from "../../../../accessibility/RovingTabIndex";
5252
import { mediaFromMxc } from "../../../../customisations/Media";
5353
import { Action } from "../../../../dispatcher/actions";
@@ -537,7 +537,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
537537
const node = rovingContext.state.nodes[0];
538538
if (node) {
539539
rovingContext.dispatch({
540-
type: Type.SetFocus,
540+
type: RovingTabIndexActionType.SetFocus,
541541
payload: { node },
542542
});
543543
node?.scrollIntoView?.({
@@ -1211,7 +1211,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
12111211

12121212
if (node) {
12131213
rovingContext.dispatch({
1214-
type: Type.SetFocus,
1214+
type: RovingTabIndexActionType.SetFocus,
12151215
payload: { node },
12161216
});
12171217
node?.scrollIntoView({

apps/web/src/components/views/emojipicker/EmojiPicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
type IAction as RovingAction,
2626
type IState as RovingState,
2727
RovingTabIndexProvider,
28-
Type,
28+
RovingTabIndexActionType,
2929
} from "../../../accessibility/RovingTabIndex";
3030
import { Key } from "../../../Keyboard";
3131
import { type ButtonEvent } from "../elements/AccessibleButton";
@@ -187,7 +187,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
187187
focusNode?.focus();
188188
}
189189
dispatch({
190-
type: Type.SetFocus,
190+
type: RovingTabIndexActionType.SetFocus,
191191
payload: { node: focusNode },
192192
});
193193

@@ -212,7 +212,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
212212
// Reset to first emoji when showing highlight for the first time (or after it was hidden)
213213
if (state.nodes.length > 0) {
214214
dispatch({
215-
type: Type.SetFocus,
215+
type: RovingTabIndexActionType.SetFocus,
216216
payload: { node: state.nodes[0] },
217217
});
218218
}

packages/shared-components/src/core/roving/RovingTabIndex.test.tsx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ import userEvent from "@testing-library/user-event";
1010
import { act, fireEvent, render } from "@test-utils";
1111
import { describe, expect, it, vi } from "vitest";
1212

13-
import { reducer, RovingAction, RovingTabIndexProvider, RovingTabIndexWrapper, Type, useRovingTabIndex } from ".";
13+
import {
14+
RovingAction,
15+
RovingTabIndexActionType,
16+
RovingTabIndexProvider,
17+
RovingTabIndexWrapper,
18+
useRovingTabIndex,
19+
} from ".";
1420
import type { IState } from ".";
21+
import { reducer } from "./RovingTabIndex";
1522

1623
const Button = (props: HTMLAttributes<HTMLButtonElement>): React.JSX.Element => {
1724
const [onFocus, isActive, ref] = useRovingTabIndex<HTMLButtonElement>();
@@ -175,7 +182,7 @@ describe("RovingTabIndex", () => {
175182
nodes: [node1, node2],
176183
},
177184
{
178-
type: Type.SetFocus,
185+
type: RovingTabIndexActionType.SetFocus,
179186
payload: {
180187
node: node2,
181188
},
@@ -198,7 +205,7 @@ describe("RovingTabIndex", () => {
198205
};
199206

200207
state = reducer(state, {
201-
type: Type.Unregister,
208+
type: RovingTabIndexActionType.Unregister,
202209
payload: {
203210
node: unregisterButton2,
204211
},
@@ -208,7 +215,7 @@ describe("RovingTabIndex", () => {
208215
});
209216

210217
state = reducer(state, {
211-
type: Type.Unregister,
218+
type: RovingTabIndexActionType.Unregister,
212219
payload: {
213220
node: unregisterButton3,
214221
},
@@ -218,7 +225,7 @@ describe("RovingTabIndex", () => {
218225
});
219226

220227
state = reducer(state, {
221-
type: Type.Unregister,
228+
type: RovingTabIndexActionType.Unregister,
222229
payload: {
223230
node: unregisterButton4,
224231
},
@@ -228,7 +235,7 @@ describe("RovingTabIndex", () => {
228235
});
229236

230237
state = reducer(state, {
231-
type: Type.Unregister,
238+
type: RovingTabIndexActionType.Unregister,
232239
payload: {
233240
node: unregisterButton1,
234241
},
@@ -258,7 +265,7 @@ describe("RovingTabIndex", () => {
258265
};
259266

260267
state = reducer(state, {
261-
type: Type.Register,
268+
type: RovingTabIndexActionType.Register,
262269
payload: {
263270
node: ref1.current!,
264271
},
@@ -269,7 +276,7 @@ describe("RovingTabIndex", () => {
269276
});
270277

271278
state = reducer(state, {
272-
type: Type.Register,
279+
type: RovingTabIndexActionType.Register,
273280
payload: {
274281
node: ref2.current!,
275282
},
@@ -280,7 +287,7 @@ describe("RovingTabIndex", () => {
280287
});
281288

282289
state = reducer(state, {
283-
type: Type.Register,
290+
type: RovingTabIndexActionType.Register,
284291
payload: {
285292
node: ref3.current!,
286293
},
@@ -291,7 +298,7 @@ describe("RovingTabIndex", () => {
291298
});
292299

293300
state = reducer(state, {
294-
type: Type.Register,
301+
type: RovingTabIndexActionType.Register,
295302
payload: {
296303
node: ref4.current!,
297304
},
@@ -302,7 +309,7 @@ describe("RovingTabIndex", () => {
302309
});
303310

304311
state = reducer(state, {
305-
type: Type.SetFocus,
312+
type: RovingTabIndexActionType.SetFocus,
306313
payload: {
307314
node: ref2.current!,
308315
},
@@ -313,7 +320,7 @@ describe("RovingTabIndex", () => {
313320
});
314321

315322
state = reducer(state, {
316-
type: Type.Unregister,
323+
type: RovingTabIndexActionType.Unregister,
317324
payload: {
318325
node: ref2.current!,
319326
},
@@ -324,7 +331,7 @@ describe("RovingTabIndex", () => {
324331
});
325332

326333
state = reducer(state, {
327-
type: Type.Register,
334+
type: RovingTabIndexActionType.Register,
328335
payload: {
329336
node: ref2.current!,
330337
},
@@ -335,13 +342,13 @@ describe("RovingTabIndex", () => {
335342
});
336343

337344
state = reducer(state, {
338-
type: Type.Unregister,
345+
type: RovingTabIndexActionType.Unregister,
339346
payload: {
340347
node: ref1.current!,
341348
},
342349
});
343350
state = reducer(state, {
344-
type: Type.Unregister,
351+
type: RovingTabIndexActionType.Unregister,
345352
payload: {
346353
node: ref4.current!,
347354
},
@@ -352,14 +359,14 @@ describe("RovingTabIndex", () => {
352359
});
353360

354361
state = reducer(state, {
355-
type: Type.Register,
362+
type: RovingTabIndexActionType.Register,
356363
payload: {
357364
node: ref1.current!,
358365
},
359366
});
360367

361368
state = reducer(state, {
362-
type: Type.Register,
369+
type: RovingTabIndexActionType.Register,
363370
payload: {
364371
node: ref4.current!,
365372
},

0 commit comments

Comments
 (0)