Skip to content

Commit

Permalink
Add tooltip to participant items only on overflow (#4728)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leah-Xia-Microsoft authored Jun 13, 2024
1 parent 6042c05 commit 04bc499
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
headingMoreButtonStyles
} from './styles/ParticipantContainer.styles';
import { ParticipantList, ParticipantListProps, ParticipantMenuItemsCallback } from '@internal/react-components';
import { FocusZone, Stack, Text, useTheme } from '@fluentui/react';
import { FocusZone, Stack, Text, TooltipHost, TooltipOverflowMode, getId, useTheme } from '@fluentui/react';
import { DefaultButton, IContextualMenuProps } from '@fluentui/react';
import { AvatarPersona, AvatarPersonaDataCallback } from './AvatarPersona';
import { useId } from '@fluentui/react-hooks';
Expand Down Expand Up @@ -67,6 +67,7 @@ export const ParticipantListWithHeading = (props: {
const theme = useTheme();
/* @conditional-compile-remove(total-participant-count) */
const totalParticipantCount = participantListProps.totalParticipantCount;
const tooltipId: string = getId('text-tooltip');
const subheadingStyleThemed = useMemo(
() => ({
root: {
Expand Down Expand Up @@ -117,9 +118,13 @@ export const ParticipantListWithHeading = (props: {
allowActiveBorder={true}
/>
{options?.text && (
<Text nowrap={true} styles={displayNameStyles}>
{options?.text}
</Text>
<div style={displayNameStyles}>
<TooltipHost content={options?.text} id={tooltipId} overflowMode={TooltipOverflowMode.Parent}>
<Text nowrap={false} aria-labelledby={tooltipId}>
{options?.text}
</Text>
</TooltipHost>
</div>
)}
</>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
IStackStyles,
IStackItemStyles,
IStackTokens,
mergeStyles,
Theme,
ITextStyles,
IButtonStyles
} from '@fluentui/react';
import { IStackStyles, IStackItemStyles, IStackTokens, mergeStyles, Theme, IButtonStyles } from '@fluentui/react';
import { ParticipantListStyles } from '@internal/react-components';
import { CHAT_CONTAINER_ZINDEX } from '../../ChatComposite/styles/Chat.styles';

Expand Down Expand Up @@ -169,12 +161,11 @@ export const participantListMobileStyle: ParticipantListStyles = {
/**
* @private
*/
export const displayNameStyles: ITextStyles = {
root: {
padding: '0.5rem',
textOverflow: 'ellipsis',
overflow: 'hidden'
}
export const displayNameStyles = {
padding: '0.5rem',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap'
};

/**
Expand Down

0 comments on commit 04bc499

Please sign in to comment.