From ad673813976669797202c2cefc50274aca84989d Mon Sep 17 00:00:00 2001 From: sct Date: Wed, 14 Apr 2021 10:39:07 +0900 Subject: [PATCH] fix(ui): close sidebar on mobile when clicking version status --- src/components/Layout/Sidebar/index.tsx | 6 ++++-- src/components/Layout/VersionStatus/index.tsx | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/Layout/Sidebar/index.tsx b/src/components/Layout/Sidebar/index.tsx index d33f66cb8..7558b95ba 100644 --- a/src/components/Layout/Sidebar/index.tsx +++ b/src/components/Layout/Sidebar/index.tsx @@ -174,7 +174,7 @@ const Sidebar: React.FC = ({ open, setClosed }) => {
@@ -223,7 +223,9 @@ const Sidebar: React.FC = ({ open, setClosed }) => { ); })} - {hasPermission(Permission.ADMIN) && } + {hasPermission(Permission.ADMIN) && ( + setClosed()} /> + )}
diff --git a/src/components/Layout/VersionStatus/index.tsx b/src/components/Layout/VersionStatus/index.tsx index f746dbc81..e5e07869c 100644 --- a/src/components/Layout/VersionStatus/index.tsx +++ b/src/components/Layout/VersionStatus/index.tsx @@ -12,7 +12,11 @@ const messages = defineMessages({ '{commitsBehind} {commitsBehind, plural, one {commit} other {commits}} behind', }); -const VersionStatus: React.FC = () => { +interface VersionStatusProps { + onClick?: () => void; +} + +const VersionStatus: React.FC = ({ onClick }) => { const intl = useIntl(); const { data } = useSWR('/api/v1/status', { refreshInterval: 60 * 1000, @@ -32,6 +36,14 @@ const VersionStatus: React.FC = () => { return ( { + if (e.key === 'Enter' && onClick) { + onClick(); + } + }} + role="button" + tabIndex={0} className={`flex items-center p-2 mx-2 text-xs transition duration-300 rounded-lg ring-1 ring-gray-700 ${ data.updateAvailable ? 'bg-yellow-500 text-white hover:bg-yellow-400'