Skip to content

Commit 04bc499

Browse files
Add tooltip to participant items only on overflow (#4728)
1 parent 6042c05 commit 04bc499

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

packages/react-composites/src/composites/common/ParticipantContainer.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
headingMoreButtonStyles
1313
} from './styles/ParticipantContainer.styles';
1414
import { ParticipantList, ParticipantListProps, ParticipantMenuItemsCallback } from '@internal/react-components';
15-
import { FocusZone, Stack, Text, useTheme } from '@fluentui/react';
15+
import { FocusZone, Stack, Text, TooltipHost, TooltipOverflowMode, getId, useTheme } from '@fluentui/react';
1616
import { DefaultButton, IContextualMenuProps } from '@fluentui/react';
1717
import { AvatarPersona, AvatarPersonaDataCallback } from './AvatarPersona';
1818
import { useId } from '@fluentui/react-hooks';
@@ -67,6 +67,7 @@ export const ParticipantListWithHeading = (props: {
6767
const theme = useTheme();
6868
/* @conditional-compile-remove(total-participant-count) */
6969
const totalParticipantCount = participantListProps.totalParticipantCount;
70+
const tooltipId: string = getId('text-tooltip');
7071
const subheadingStyleThemed = useMemo(
7172
() => ({
7273
root: {
@@ -117,9 +118,13 @@ export const ParticipantListWithHeading = (props: {
117118
allowActiveBorder={true}
118119
/>
119120
{options?.text && (
120-
<Text nowrap={true} styles={displayNameStyles}>
121-
{options?.text}
122-
</Text>
121+
<div style={displayNameStyles}>
122+
<TooltipHost content={options?.text} id={tooltipId} overflowMode={TooltipOverflowMode.Parent}>
123+
<Text nowrap={false} aria-labelledby={tooltipId}>
124+
{options?.text}
125+
</Text>
126+
</TooltipHost>
127+
</div>
123128
)}
124129
</>
125130
)}

packages/react-composites/src/composites/common/styles/ParticipantContainer.styles.ts

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
import {
5-
IStackStyles,
6-
IStackItemStyles,
7-
IStackTokens,
8-
mergeStyles,
9-
Theme,
10-
ITextStyles,
11-
IButtonStyles
12-
} from '@fluentui/react';
4+
import { IStackStyles, IStackItemStyles, IStackTokens, mergeStyles, Theme, IButtonStyles } from '@fluentui/react';
135
import { ParticipantListStyles } from '@internal/react-components';
146
import { CHAT_CONTAINER_ZINDEX } from '../../ChatComposite/styles/Chat.styles';
157

@@ -169,12 +161,11 @@ export const participantListMobileStyle: ParticipantListStyles = {
169161
/**
170162
* @private
171163
*/
172-
export const displayNameStyles: ITextStyles = {
173-
root: {
174-
padding: '0.5rem',
175-
textOverflow: 'ellipsis',
176-
overflow: 'hidden'
177-
}
164+
export const displayNameStyles = {
165+
padding: '0.5rem',
166+
textOverflow: 'ellipsis',
167+
overflow: 'hidden',
168+
whiteSpace: 'nowrap'
178169
};
179170

180171
/**

0 commit comments

Comments
 (0)