diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx index 4375018765aea..c72e57d06abbf 100644 --- a/packages/trace-viewer/src/ui/uiModeView.tsx +++ b/packages/trace-viewer/src/ui/uiModeView.tsx @@ -354,6 +354,18 @@ export const UIModeView: React.FC<{}> = ({ return () => disposable.dispose(); }, [runTests, testServerConnection, watchAll, watchedTreeIds, teleSuiteUpdater, projectFilters]); + const hideOutput = React.useCallback(() => setIsShowingOutput(false), [setIsShowingOutput]); + const showOutput = React.useCallback(() => { + setIsShowingOutput(true); + setOutputContainsError(false); + }, [setIsShowingOutput, setOutputContainsError]); + const toggleOutput = React.useCallback(() => { + if (isShowingOutput) + hideOutput(); + else + showOutput(); + }, [isShowingOutput, showOutput, hideOutput]); + // Shortcuts. React.useEffect(() => { if (!testServerConnection) @@ -361,7 +373,7 @@ export const UIModeView: React.FC<{}> = ({ const onShortcutEvent = (e: KeyboardEvent) => { if (e.code === 'Backquote' && e.ctrlKey) { e.preventDefault(); - setIsShowingOutput(!isShowingOutput); + toggleOutput(); } else if (e.code === 'F5' && e.shiftKey) { e.preventDefault(); testServerConnection?.stopTestsNoReply({}); @@ -374,7 +386,7 @@ export const UIModeView: React.FC<{}> = ({ return () => { removeEventListener('keydown', onShortcutEvent); }; - }, [runTests, reloadTests, testServerConnection, visibleTestIds, isShowingOutput]); + }, [runTests, reloadTests, testServerConnection, visibleTestIds, toggleOutput]); const dialogRef = React.useRef(null); const openInstallDialog = React.useCallback((e: React.MouseEvent) => { @@ -389,13 +401,13 @@ export const UIModeView: React.FC<{}> = ({ }, []); const installBrowsers = React.useCallback((e: React.MouseEvent) => { closeInstallDialog(e); - setIsShowingOutput(true); + showOutput(); testServerConnection?.installBrowsers({}).then(async () => { - setIsShowingOutput(false); + hideOutput(); const { hasBrowsers } = await testServerConnection?.checkBrowsers({}); setHasBrowsers(hasBrowsers); }); - }, [closeInstallDialog, testServerConnection]); + }, [closeInstallDialog, testServerConnection, showOutput, hideOutput]); return
{!hasBrowsers && @@ -425,7 +437,7 @@ export const UIModeView: React.FC<{}> = ({
Output
{ xtermDataSource.clear(); setOutputContainsError(false); }}>
- setIsShowingOutput(false)}> +
@@ -445,8 +457,9 @@ export const UIModeView: React.FC<{}> = ({
Playwright
reloadTests()} disabled={isRunningTest || isLoading}>
- { setIsShowingOutput(!isShowingOutput); }} /> - {outputContainsError &&
} + + {outputContainsError &&
} +
{!hasBrowsers && } diff --git a/packages/web/src/components/toolbarButton.tsx b/packages/web/src/components/toolbarButton.tsx index fbdfb738abbe5..1fd27ffbaba52 100644 --- a/packages/web/src/components/toolbarButton.tsx +++ b/packages/web/src/components/toolbarButton.tsx @@ -29,6 +29,7 @@ export interface ToolbarButtonProps { testId?: string, className?: string, ariaLabel?: string, + noChildMargin?: boolean, } export const ToolbarButton = React.forwardRef>(function ToolbarButton({ @@ -42,6 +43,7 @@ export const ToolbarButton = React.forwardRef - {icon && } + {icon && } {children} ; });