Skip to content

Commit 8f5f699

Browse files
committed
Streamline navigation with keyboard
1 parent ff55053 commit 8f5f699

File tree

6 files changed

+24
-33
lines changed

6 files changed

+24
-33
lines changed

src/renderer/ColorButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const ColorButton = (props: ColorButtonProps): ReactNode => {
1717
return (
1818
<Popover positioning="below-start" trapFocus={true}>
1919
<PopoverTrigger>
20-
<Button icon={<ColorWell color={props.color} />} title="Color"></Button>
20+
<Button icon={<ColorWell color={props.color} />} title="Color" />
2121
</PopoverTrigger>
2222
<PopoverSurface>
2323
<ColorPicker

src/renderer/GraphBar.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ export const GraphBar = (props: GraphBarProps): ReactNode => {
5050
const dispatch = useDispatch();
5151
const graph = useSelector((s) => s.graphs.byId[props.graphId]);
5252
const relationInputActionsRef = useRef<RelationInputActions>(null);
53-
const tabsterAttributes = useTabsterAttributes({
53+
const dragHandleTabsterAttributes = useTabsterAttributes({
5454
focusable: {
5555
ignoreKeydown: {
56-
ArrowDown: true,
57-
ArrowLeft: true,
58-
ArrowRight: true,
59-
ArrowUp: true,
60-
End: true,
61-
Home: true,
62-
PageDown: true,
63-
PageUp: true,
64-
Tab: true,
56+
ArrowDown: draggingWithKeyboard,
57+
ArrowLeft: draggingWithKeyboard,
58+
ArrowRight: draggingWithKeyboard,
59+
ArrowUp: draggingWithKeyboard,
60+
End: draggingWithKeyboard,
61+
Home: draggingWithKeyboard,
62+
PageDown: draggingWithKeyboard,
63+
PageUp: draggingWithKeyboard,
64+
Tab: draggingWithKeyboard,
6565
},
6666
},
6767
});
@@ -84,7 +84,7 @@ export const GraphBar = (props: GraphBarProps): ReactNode => {
8484
<Toolbar style={{ background: tokens.colorNeutralBackground1 }}>
8585
<ToolbarButton
8686
{...dragHandleProps}
87-
{...(draggingWithKeyboard ? tabsterAttributes : {})}
87+
{...dragHandleTabsterAttributes}
8888
appearance="transparent"
8989
icon={<ReOrderDotsVerticalRegular />}
9090
style={{

src/renderer/GraphView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export const GraphView = (
7171
const store = useStore<AppState>();
7272
const secondMount = useRef(false);
7373
const styles = useStyles();
74-
const arrowNavigationGroup = useArrowNavigationGroup({ axis: "vertical" });
74+
const arrowNavigationGroup = useArrowNavigationGroup({
75+
axis: "both",
76+
circular: true,
77+
});
7578
const [canZoomIn, setCanZoomIn] = useState(false);
7679
const [canZoomOut, setCanZoomOut] = useState(false);
7780

src/renderer/PenButton.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ export const PenButton = (props: PenButtonProps): ReactNode => {
3131
props.thickness.toString(),
3232
);
3333
const [thicknessErrorMessage, setThicknessErrorMessage] = useState<string>();
34-
const arrowNavigationGroup = useArrowNavigationGroup({ axis: "horizontal" });
34+
const arrowNavigationGroup = useArrowNavigationGroup({
35+
axis: "horizontal",
36+
circular: true,
37+
});
3538

3639
const validateThickness = useMemo(
3740
() =>

src/renderer/RelationInput.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useTabsterAttributes } from "@fluentui/react-tabster";
21
import { debounce } from "lodash";
32
import {
43
ReactNode,
@@ -332,21 +331,6 @@ export const RelationInput = (props: RelationInputProps): ReactNode => {
332331
const [validationError, setValidationError] = useState<RelationError>();
333332
const [showValidationError, setShowValidationError] = useState(false);
334333

335-
const tabsterAttributes = useTabsterAttributes({
336-
focusable: {
337-
ignoreKeydown: {
338-
ArrowDown: true,
339-
ArrowLeft: true,
340-
ArrowRight: true,
341-
ArrowUp: true,
342-
End: true,
343-
Home: true,
344-
PageDown: true,
345-
PageUp: true,
346-
},
347-
},
348-
});
349-
350334
const decorate = useCallback(
351335
(entry: S.NodeEntry): S.Range[] => {
352336
const [node, path] = entry;
@@ -514,7 +498,6 @@ export const RelationInput = (props: RelationInputProps): ReactNode => {
514498
initialValue={initialValue}
515499
>
516500
<Editable
517-
{...tabsterAttributes}
518501
className="relation-input"
519502
decorate={decorate}
520503
onKeyDown={(e) => {
@@ -551,7 +534,6 @@ export const RelationInput = (props: RelationInputProps): ReactNode => {
551534
decorate,
552535
editor,
553536
initialValue,
554-
tabsterAttributes,
555537
onEnterKeyPressed,
556538
updateRelationDebounced,
557539
updateTokens,

src/renderer/SymbolsButton.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export const SymbolsButton = (props: SymbolsButtonProps): ReactNode => {
2929
const { onDismissed } = props;
3030
const [showCallout, setShowCallout] = useState(false);
3131
const styles = useStyles();
32-
const arrowNavigationGroup = useArrowNavigationGroup({ axis: "grid-linear" });
32+
const arrowNavigationGroup = useArrowNavigationGroup({
33+
axis: "grid-linear",
34+
circular: true,
35+
});
3336

3437
const setShowCalloutDebounced = useMemo(
3538
() =>

0 commit comments

Comments
 (0)