Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tooltip when roomname is elided in the pre meeting screen #15508

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions react/features/base/premeeting/components/web/PreMeetingScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import React, { ReactNode } from 'react';
import React, { ReactNode, useEffect, useRef, useState } from 'react';
import { connect } from 'react-redux';
import { makeStyles } from 'tss-react/mui';

Expand All @@ -11,6 +11,7 @@ import { isButtonEnabled } from '../../../../toolbox/functions.web';
import { getConferenceName } from '../../../conference/functions';
import { PREMEETING_BUTTONS, THIRD_PARTY_PREJOIN_BUTTONS } from '../../../config/constants';
import { withPixelLineHeight } from '../../../styles/functions.web';
import Tooltip from '../../../tooltip/components/Tooltip';
import { isPreCallTestEnabled } from '../../functions';

import ConnectionStatus from './ConnectionStatus';
Expand Down Expand Up @@ -160,15 +161,20 @@ const useStyles = makeStyles()(theme => {
display: 'none'
}
},
roomNameContainer: {
width: '100%',
textAlign: 'center',
marginBottom: theme.spacing(4)
},

roomName: {
...withPixelLineHeight(theme.typography.heading5),
color: theme.palette.text01,
marginBottom: theme.spacing(4),
display: 'inline-block',
overflow: 'hidden',
textAlign: 'center',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
width: '100%'
maxWidth: '100%',
}
};
});
Expand All @@ -195,6 +201,19 @@ const PreMeetingScreen = ({
backgroundSize: 'cover'
} : {};

const roomNameRef = useRef<HTMLSpanElement | null>(null);
const [ isOverflowing, setIsOverflowing ] = useState(false);

useEffect(() => {
if (roomNameRef.current) {
const element = roomNameRef.current;
const elementStyles = window.getComputedStyle(element);
const elementWidth = Math.floor(parseFloat(elementStyles.width));

setIsOverflowing(element.scrollWidth > elementWidth + 1);
}
}, [ _roomName ]);

return (
<div className = { clsx('premeeting-screen', classes.container, className) }>
<div style = { style }>
Expand All @@ -206,8 +225,22 @@ const PreMeetingScreen = ({
{title}
</h1>
{_roomName && (
<span className = { classes.roomName }>
{_roomName}
<span className = { classes.roomNameContainer }>
{isOverflowing ? (
<Tooltip content = { _roomName }>
<span
className = { classes.roomName }
ref = { roomNameRef }>
{_roomName}
</span>
</Tooltip>
) : (
<span
className = { classes.roomName }
ref = { roomNameRef }>
{_roomName}
</span>
)}
</span>
)}
{children}
Expand Down Expand Up @@ -259,3 +292,4 @@ function mapStateToProps(state: IReduxState, ownProps: Partial<IProps>) {
}

export default connect(mapStateToProps)(PreMeetingScreen);

Loading