diff --git a/public/app/core/components/QueryOperationRow/QueryOperationRow.test.tsx b/public/app/core/components/QueryOperationRow/QueryOperationRow.test.tsx index 2efdd6a2729..3a3db9e0527 100644 --- a/public/app/core/components/QueryOperationRow/QueryOperationRow.test.tsx +++ b/public/app/core/components/QueryOperationRow/QueryOperationRow.test.tsx @@ -32,7 +32,7 @@ describe('QueryOperationRow', () => { const onCloseSpy = jest.fn(); setup({ isOpen: false, onOpen: onOpenSpy, onClose: onCloseSpy }); - const queryRow = screen.getByText(/^test-title$/); + const queryRow = screen.getByRole('button', { name: /^test-title$/ }); expect(queryRow).toBeInTheDocument(); // open row on click diff --git a/public/app/core/components/QueryOperationRow/QueryOperationRow.tsx b/public/app/core/components/QueryOperationRow/QueryOperationRow.tsx index 8b901100558..4c7d826940b 100644 --- a/public/app/core/components/QueryOperationRow/QueryOperationRow.tsx +++ b/public/app/core/components/QueryOperationRow/QueryOperationRow.tsx @@ -90,7 +90,6 @@ export function QueryOperationRow({ }, }; - const titleElement = title && ReactUtils.renderOrCallToRender(title, renderPropArgs); const actionsElement = actions && ReactUtils.renderOrCallToRender(actions, renderPropArgs); const headerElementRendered = headerElement && ReactUtils.renderOrCallToRender(headerElement, renderPropArgs); @@ -112,7 +111,7 @@ export function QueryOperationRow({ isContentVisible={isContentVisible} onRowToggle={onRowToggle} reportDragMousePosition={reportDragMousePosition} - titleElement={titleElement} + title={title} /> {isContentVisible &&
{children}
} @@ -135,7 +134,7 @@ export function QueryOperationRow({ isContentVisible={isContentVisible} onRowToggle={onRowToggle} reportDragMousePosition={reportDragMousePosition} - titleElement={titleElement} + title={title} /> {isContentVisible &&
{children}
} diff --git a/public/app/core/components/QueryOperationRow/QueryOperationRowHeader.tsx b/public/app/core/components/QueryOperationRow/QueryOperationRowHeader.tsx index 3e1873571d7..76df2471d05 100644 --- a/public/app/core/components/QueryOperationRow/QueryOperationRowHeader.tsx +++ b/public/app/core/components/QueryOperationRow/QueryOperationRowHeader.tsx @@ -1,4 +1,5 @@ import { css, cx } from '@emotion/css'; +import { useId } from '@react-aria/utils'; import React, { MouseEventHandler } from 'react'; import { DraggableProvidedDragHandleProps } from 'react-beautiful-dnd'; @@ -14,7 +15,7 @@ interface QueryOperationRowHeaderProps { isContentVisible: boolean; onRowToggle: () => void; reportDragMousePosition: MouseEventHandler; - titleElement?: React.ReactNode; + title?: string; id: string; } @@ -27,10 +28,11 @@ export const QueryOperationRowHeader: React.FC = ( isContentVisible, onRowToggle, reportDragMousePosition, - titleElement, + title, id, }: QueryOperationRowHeaderProps) => { const styles = useStyles2(getStyles); + const titleId = useId(); return (
@@ -44,10 +46,13 @@ export const QueryOperationRowHeader: React.FC = ( type="button" aria-expanded={isContentVisible} aria-controls={id} + aria-labelledby={titleId} /> - {titleElement && ( -
-
{titleElement}
+ {title && ( +
+
+ {title} +
)} {headerElement} @@ -109,13 +114,11 @@ const getStyles = (theme: GrafanaTheme2) => ({ display: flex; align-items: center; flex-grow: 1; - cursor: pointer; overflow: hidden; margin-right: ${theme.spacing(0.5)}; `, title: css` font-weight: ${theme.typography.fontWeightBold}; - color: ${theme.colors.text.link}; margin-left: ${theme.spacing(0.5)}; overflow: hidden; text-overflow: ellipsis; diff --git a/public/app/features/inspector/InspectDataTab.test.tsx b/public/app/features/inspector/InspectDataTab.test.tsx index 0dc821cb758..547fb927abf 100644 --- a/public/app/features/inspector/InspectDataTab.test.tsx +++ b/public/app/features/inspector/InspectDataTab.test.tsx @@ -50,14 +50,14 @@ describe('InspectDataTab', () => { }); it('should show available options', async () => { render(); - const dataOptions = screen.getByText(/Data options/i); + const dataOptions = screen.getByRole('button', { name: /Data options/i }); await userEvent.click(dataOptions); expect(screen.getByText(/Show data frame/i)).toBeInTheDocument(); expect(screen.getByText(/Download for Excel/i)).toBeInTheDocument(); }); it('should show available dataFrame options', async () => { render(); - const dataOptions = screen.getByText(/Data options/i); + const dataOptions = screen.getByRole('button', { name: /Data options/i }); await userEvent.click(dataOptions); const dataFrameInput = screen.getByRole('combobox', { name: /Select dataframe/i }); await userEvent.click(dataFrameInput);