From b5dd668609a114578e806cdb82e9a96821f6cfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 23 Jul 2023 19:22:15 +0200 Subject: [PATCH] Improve focus handlding and focused state styles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/components/account.tsx | 1 + app/soapbox/components/ui/tabs/tabs.css | 3 ++- app/soapbox/components/ui/toggle/toggle.tsx | 3 ++- app/soapbox/features/chats/components/chat-list-item.tsx | 9 ++++++++- .../features/edit-profile/components/header-picker.tsx | 1 + .../modals/compose-event-modal/upload-button.tsx | 2 +- app/soapbox/features/ui/components/profile-dropdown.tsx | 7 ++++++- 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/soapbox/components/account.tsx b/app/soapbox/components/account.tsx index 861b8d475..9536ef6ed 100644 --- a/app/soapbox/components/account.tsx +++ b/app/soapbox/components/account.tsx @@ -189,6 +189,7 @@ const Account = ({ wrapper={(children) => {children}} > event.stopPropagation()} diff --git a/app/soapbox/components/ui/tabs/tabs.css b/app/soapbox/components/ui/tabs/tabs.css index 366211c32..e5cb6fe4a 100644 --- a/app/soapbox/components/ui/tabs/tabs.css +++ b/app/soapbox/components/ui/tabs/tabs.css @@ -13,7 +13,8 @@ [data-reach-tab] { @apply flex-1 flex justify-center items-center py-4 px-1 text-center font-medium text-sm text-gray-700 - dark:text-gray-600 hover:text-gray-800 dark:hover:text-gray-500; + dark:text-gray-600 hover:text-gray-800 dark:hover:text-gray-500 + focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 dark:ring-gray-800 dark:ring-offset-0 dark:focus-visible:ring-primary-500; } [data-reach-tab][data-selected] { diff --git a/app/soapbox/components/ui/toggle/toggle.tsx b/app/soapbox/components/ui/toggle/toggle.tsx index 0311da8ac..abf7933c5 100644 --- a/app/soapbox/components/ui/toggle/toggle.tsx +++ b/app/soapbox/components/ui/toggle/toggle.tsx @@ -16,7 +16,7 @@ const Toggle: React.FC = ({ id, size = 'md', name, checked, onChange, r return ( ); diff --git a/app/soapbox/features/chats/components/chat-list-item.tsx b/app/soapbox/features/chats/components/chat-list-item.tsx index 9b54de9ed..82796283d 100644 --- a/app/soapbox/features/chats/components/chat-list-item.tsx +++ b/app/soapbox/features/chats/components/chat-list-item.tsx @@ -62,14 +62,21 @@ const ChatListItem: React.FC = ({ chat, onClick }) => { icon: require('@tabler/icons/logout.svg'), }], []); + const handleKeyDown: React.KeyboardEventHandler = (event) => { + if (event.key === 'Enter' || event.key === ' ') { + onClick(chat); + } + }; + return ( - // eslint-disable-next-line jsx-a11y/interactive-supports-focus
onClick(chat)} + onKeyDown={handleKeyDown} className='group flex w-full flex-col rounded-lg px-2 py-3 hover:bg-gray-100 focus:shadow-inset-ring dark:hover:bg-gray-800' data-testid='chat-list-item' + tabIndex={0} > diff --git a/app/soapbox/features/edit-profile/components/header-picker.tsx b/app/soapbox/features/edit-profile/components/header-picker.tsx index 8339f95ff..036814713 100644 --- a/app/soapbox/features/edit-profile/components/header-picker.tsx +++ b/app/soapbox/features/edit-profile/components/header-picker.tsx @@ -29,6 +29,7 @@ const HeaderPicker = React.forwardRef(({ src, onC