Skip to content

Commit 1f3f022

Browse files
authored
refactor(assistant): Improve accessibility with semantic heading and Fluent UI Subtitle2 component (#8711)
* Update tag and styles for header * Add unit test
1 parent f42fd56 commit 1f3f022

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

libs/chatbot/src/lib/ui/__test__/panelheader.spec.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ describe('ui/panelheader/CopilotPanelHeader', () => {
126126
expect(icon.tagName.toLowerCase()).toBe('img');
127127
});
128128

129+
it('should use semantic h2 heading for the header title', () => {
130+
renderWithProviders(<CopilotPanelHeader closeCopilot={closeCopilotMock} />);
131+
132+
const heading = screen.getByRole('heading', { level: 2, name: 'Workflow assistant' });
133+
expect(heading).toBeDefined();
134+
});
135+
129136
it('should have aria-label on protected pill tooltip for screen readers', () => {
130137
renderWithProviders(<CopilotPanelHeader closeCopilot={closeCopilotMock} />);
131138

libs/chatbot/src/lib/ui/panelheader.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Workflow from '../images/Workflow.svg';
22
import { FontSizes, Link, useTheme } from '@fluentui/react';
3-
import { Tooltip, mergeClasses } from '@fluentui/react-components';
3+
import { Tooltip, mergeClasses, Subtitle2 } from '@fluentui/react-components';
44
import { ShieldCheckmarkRegular } from '@fluentui/react-icons';
55
import { IconButton } from '@fluentui/react/lib/Button';
66
import { LogEntryLevel, LoggerService } from '@microsoft/logic-apps-shared';
@@ -50,9 +50,9 @@ export const CopilotPanelHeader = ({ closeCopilot }: CopilotPanelHeaderProps): J
5050
<div className={styles.headerIcon}>
5151
<img src={Workflow} alt="Logic Apps" />
5252
</div>
53-
<div className={styles.headerTitleContainer}>
54-
<div className={styles.headerTitle}>{headerTitle}</div>
55-
<div className={mergeClasses(styles.headerSubtitle, isInverted && darkStyles.headerSubtitle)}>{subtitleText}</div>
53+
<div>
54+
<h2 className={styles.headerTitle}>{headerTitle}</h2>
55+
<Subtitle2 className={mergeClasses(styles.headerSubtitle, isInverted && darkStyles.headerSubtitle)}>{subtitleText}</Subtitle2>
5656
</div>
5757
<div>
5858
<Tooltip content={protectedMessage} relationship="label" positioning="below" withArrow>

libs/chatbot/src/lib/ui/styles.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ export const useChatbotStyles = makeStyles({
4040
...shorthands.margin(0, 0, '5px', '5px'),
4141
},
4242

43-
headerTitleContainer: {
44-
// Nested styles handled in separate classes
45-
},
46-
4743
headerTitle: {
4844
fontWeight: tokens.fontWeightSemibold,
4945
fontSize: tokens.fontSizeBase400,
@@ -56,9 +52,10 @@ export const useChatbotStyles = makeStyles({
5652
width: 'fit-content',
5753
fontSize: tokens.fontSizeBase200,
5854
fontWeight: tokens.fontWeightRegular,
59-
...shorthands.borderRadius(tokens.borderRadiusCircular),
55+
borderRadius: tokens.borderRadiusCircular,
6056
lineHeight: '15px',
6157
color: tokens.colorNeutralForeground2,
58+
display: 'block',
6259
},
6360

6461
// Mode pill styles

0 commit comments

Comments
 (0)