Skip to content

Commit b15bff8

Browse files
committed
fix dom integrity
1 parent 7aa39d9 commit b15bff8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

__tests__/html/accessibility.activity.stackedLayoutRole.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
await pageConditions.minNumActivitiesShown(2);
2424
await pageConditions.scrollToBottomCompleted();
2525

26-
const messageRole = document.querySelector('.webchat__stacked-layout__message-row').getAttribute('role');
26+
const messageRole = document.querySelector('.stacked-layout__message-row').getAttribute('role');
2727

2828
expect(messageRole).toEqual('group');
2929
});

packages/component/src/Activity/StackedLayout.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ const { useAvatarForBot, useAvatarForUser, useLocalizer, useStyleOptions } = hoo
2424

2525
type StackedLayoutInnerProps = Readonly<{
2626
activity: WebChatActivity;
27-
hasDisplayText: boolean;
28-
hasAttachments: boolean;
2927
children?: ReactNode | undefined;
3028
fromUser: boolean;
29+
hasAttachments: boolean;
30+
hasDisplayText: boolean;
31+
id: string;
3132
renderAvatar?: false | (() => Exclude<ReactNode, boolean | null | undefined>) | undefined;
3233
renderBubbleContent: (title?: string | undefined) => ReactNode;
3334
showCallout?: boolean | undefined;
@@ -36,18 +37,18 @@ type StackedLayoutInnerProps = Readonly<{
3637
const StackedLayoutInner = memo(
3738
({
3839
activity,
39-
hasDisplayText,
40-
hasAttachments,
4140
children,
4241
fromUser,
42+
hasAttachments,
43+
hasDisplayText,
44+
id,
4345
renderAvatar,
4446
renderBubbleContent,
4547
showCallout
4648
}: StackedLayoutInnerProps) => {
4749
const [styleOptions] = useStyleOptions();
4850
const [{ initials: botInitials }] = useAvatarForBot();
4951
const [{ initials: userInitials }] = useAvatarForUser();
50-
const ariaLabelId = useUniqueId('webchat__stacked-layout__main');
5152
const localize = useLocalizer();
5253
const classNames = useStyles(styles);
5354

@@ -80,7 +81,7 @@ const StackedLayoutInner = memo(
8081
className={cx(classNames['stacked-layout__message-row'])}
8182
// Disable "Prop `id` is forbidden on DOM Nodes" rule because we are using the ID prop for accessibility.
8283
/* eslint-disable-next-line react/forbid-dom-props */
83-
id={ariaLabelId}
84+
id={id}
8485
role="group"
8586
>
8687
<ScreenReaderText text={greetingAlt} />
@@ -281,6 +282,7 @@ const StackedLayout = ({
281282
fromUser={fromUser}
282283
hasAttachments={attachmentChildren.length > 0}
283284
hasDisplayText={!!activityDisplayText?.length || isCollapsible}
285+
id={ariaLabelId}
284286
renderAvatar={renderAvatar}
285287
renderBubbleContent={renderBubbleContent}
286288
showCallout={showCallout}

0 commit comments

Comments
 (0)