From 66d6f6f35bec0b5362e60c745c0746e7cecdaa0e Mon Sep 17 00:00:00 2001 From: Khuda Dad Nomani Date: Thu, 4 Apr 2024 00:44:27 +0100 Subject: [PATCH] fix sonar --- .../Modals/Settings/SettingsTabs.tsx | 4 ++ .../src/components/Terminal/TerminalInfo.tsx | 11 +++- .../src/components/Terminal/TerminalTabs.tsx | 58 ++++++++++--------- .../src/components/common/Dropdown.tsx | 4 ++ .../src/components/common/Switch.tsx | 16 +++-- 5 files changed, 58 insertions(+), 35 deletions(-) diff --git a/apps/studio-next/src/components/Modals/Settings/SettingsTabs.tsx b/apps/studio-next/src/components/Modals/Settings/SettingsTabs.tsx index c53bda074..2127ef2cd 100644 --- a/apps/studio-next/src/components/Modals/Settings/SettingsTabs.tsx +++ b/apps/studio-next/src/components/Modals/Settings/SettingsTabs.tsx @@ -36,6 +36,10 @@ export const SettingsTabs: FunctionComponent = ({ key={tab.name} className="cursor-pointer" onClick={() => setActiveTab(tab.name)} + tabIndex={0} + onKeyDown={(event) => { + if (event.key === 'Enter' || event.key === ' ') setActiveTab(tab.name); + }} >
= () => { const actualVersion = document.document?.version() || '2.0.0'; const latestVersion = specificationSvc.latestVersion; - const onNonLatestClick = useCallback((e: ReactMouseEvent) => { + const onNonLatestClick = useCallback((e: {stopPropagation: ()=>void}) => { e.stopPropagation(); show(ConvertToLatestModal); }, []); @@ -92,7 +92,12 @@ export const TerminalInfo: FunctionComponent = () => { {autoSaving ? 'Autosave: On' : 'Autosave: Off'}
{actualVersion !== latestVersion && document.valid === true && ( -
+
{ + if (event.key === 'Enter' || event.key === ' ') onNonLatestClick(event); + }}> diff --git a/apps/studio-next/src/components/Terminal/TerminalTabs.tsx b/apps/studio-next/src/components/Terminal/TerminalTabs.tsx index 6130c91c1..47296a5a7 100644 --- a/apps/studio-next/src/components/Terminal/TerminalTabs.tsx +++ b/apps/studio-next/src/components/Terminal/TerminalTabs.tsx @@ -14,6 +14,33 @@ interface TerminalTabsProps { active?: string; } +const onTerminalTabClickHandler = (e: {currentTarget: {parentElement: any}}) => { + const clientRects = e.currentTarget.parentElement?.parentElement?.getClientRects()[0]; + if (!clientRects) return; + + const height = clientRects.height; + const calc160px = 'calc(100% - 160px)'; + const calc36px = 'calc(100% - 36px)'; + + const prevHeight = otherState.getState().editorHeight; + const newHeight = + height < 50 ? calc160px : calc36px; + if ( + prevHeight === calc160px && + newHeight === calc160px + ) { + return 'calc(100% - 161px)'; + } + if ( + prevHeight === calc36px && + newHeight === calc36px + ) { + return 'calc(100% - 37px)'; + } + + otherState.setState({ editorHeight: newHeight }); +} + export const TerminalTabs: React.FunctionComponent = ({ tabs = [], active = 0, @@ -29,32 +56,9 @@ export const TerminalTabs: React.FunctionComponent = ({
{ - const clientRects = e.currentTarget.parentElement?.parentElement?.getClientRects()[0]; - if (!clientRects) return; - - const height = clientRects.height; - const calc160px = 'calc(100% - 160px)'; - const calc36px = 'calc(100% - 36px)'; - - const prevHeight = otherState.getState().editorHeight; - const newHeight = - height < 50 ? calc160px : calc36px; - if ( - prevHeight === calc160px && - newHeight === calc160px - ) { - return 'calc(100% - 161px)'; - } - if ( - prevHeight === calc36px && - newHeight === calc36px - ) { - return 'calc(100% - 37px)'; - } - - otherState.setState({ editorHeight: newHeight }); - }} + onClick={onTerminalTabClickHandler} + tabIndex={0} + onKeyDown={onTerminalTabClickHandler} >
    {!isV3 && tabs.map(tab => ( @@ -62,6 +66,8 @@ export const TerminalTabs: React.FunctionComponent = ({ key={tab.name} className="px-2 cursor-pointer" onClick={() => setActiveTab(tab.name)} + tabIndex={0} + onKeyDown={() => setActiveTab(tab.name)} >
    = ({