From c73f604819928980894201dfa8674c2cca1720c4 Mon Sep 17 00:00:00 2001 From: Brad Ullman Date: Sat, 25 Mar 2023 03:21:58 -0700 Subject: [PATCH] Update Sidebar Setting elements to be buttons (improve accessibility) (#130) * update sidebar elements to be buttons so they are keyboard navigatable * rollback whitespace change --- components/Sidebar/Import.tsx | 24 +++++++++++++++++------- components/Sidebar/SidebarButton.tsx | 4 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/components/Sidebar/Import.tsx b/components/Sidebar/Import.tsx index 199b748..caa0bfe 100644 --- a/components/Sidebar/Import.tsx +++ b/components/Sidebar/Import.tsx @@ -2,6 +2,7 @@ import { ChatFolder, Conversation } from "@/types"; import { cleanConversationHistory } from "@/utils/app/clean"; import { IconFileImport } from "@tabler/icons-react"; import { FC } from "react"; +import { SidebarButton } from "./SidebarButton"; interface Props { onImport: (data: { conversations: Conversation[]; folders: ChatFolder[] }) => void; @@ -9,9 +10,11 @@ interface Props { export const Import: FC = ({ onImport }) => { return ( -
+ <> { @@ -31,10 +34,17 @@ export const Import: FC = ({ onImport }) => { reader.readAsText(file); }} /> -
- -
Import conversations
-
-
+ + } + onClick={() => { + const importFile = document.querySelector("#import-file") as HTMLInputElement; + if (importFile) { + importFile.click(); + } + }} + /> + ); }; diff --git a/components/Sidebar/SidebarButton.tsx b/components/Sidebar/SidebarButton.tsx index 1ba237f..8b7be3e 100644 --- a/components/Sidebar/SidebarButton.tsx +++ b/components/Sidebar/SidebarButton.tsx @@ -8,12 +8,12 @@ interface Props { export const SidebarButton: FC = ({ text, icon, onClick }) => { return ( -
{icon}
{text}
-
+ ); };