Skip to content

Commit 2fc5b40

Browse files
committed
filebrowser keyboard navigation
1 parent 9c33a3d commit 2fc5b40

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/components/Button/styles.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ function buildStyledButton({
5555
":active": {
5656
backgroundColor: getBackgroundColorActive(props),
5757
},
58+
":focus-visible": {
59+
backgroundColor: getBackgroundColorHover(props),
60+
outline: "none",
61+
},
5862
...radiusStyles({ borderRadius, group: props.group }), // this breaks the return type somehow. Something funky when spreading the emotion type
5963
} as CSSObject;
6064

src/programs/FileBrowser/DirectoryOrFile/DirectoryOrFile.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ function DirectoryOrFile({
5555
event.preventDefault();
5656
}
5757

58+
function handleKeyDown(event: React.KeyboardEvent) {
59+
if (event.key === "Enter") {
60+
openFSObject(fsObject);
61+
}
62+
}
63+
5864
return (
5965
<StyledItem
6066
selected={selected}
@@ -63,6 +69,9 @@ function DirectoryOrFile({
6369
onClick={handleClick}
6470
key={fsObject.path}
6571
onContextMenu={handleRightClick}
72+
onKeyDown={handleKeyDown}
73+
tabIndex={0}
74+
onFocus={() => setSelected(fsObject.path)}
6675
>
6776
{contextMenuOpen && (
6877
<ContextMenu

src/programs/FileBrowser/DirectoryOrFile/styles.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export const StyledItem = styled.div<{
2020
border-radius: 10px;
2121
background-color: ${(props) =>
2222
props.selected ? props.selectedColor : undefined};
23+
24+
:focus-visible {
25+
background-color: ${(p) => p.selectedColor};
26+
outline: none;
27+
}
2328
`;
2429

2530
export const StyledItemName = styled.span``;

src/programs/FileBrowser/MainContent/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface StyledMainContentProps {
55
}
66
export const StyledMainContent = styled.div<StyledMainContentProps>`
77
grid-area: main-content;
8-
padding: 20px;
8+
padding: 1%;
99
width: 100%;
1010
height: 100%;
1111
overflow-y: auto;

0 commit comments

Comments
 (0)