import React, { useEffect, useRef } from 'react'; import { ChevronLeftIcon, CrossIcon } from '@100mslive/react-icons'; import { Button } from '../../../Button'; import { Input } from '../../../Input'; import { Box, Flex } from '../../../Layout'; import { Text } from '../../../Text'; export const ChangeNameContent = ({ changeName, setCurrentName, currentName, localPeerName, isMobile, onExit, onBackClick, }: { changeName: () => Promise; setCurrentName: (name: string) => void; currentName?: string; localPeerName?: string; isMobile: boolean; onExit: () => void; onBackClick: () => void; }) => { const inputRef = useRef(null); useEffect(() => { if (isMobile) { setTimeout(() => { inputRef.current?.focus(); }, 200); } }, [isMobile]); return (
{ e.preventDefault(); await changeName(); }} > {isMobile ? : null} Change Name Your name will be visible to other participants in the session. { setCurrentName(e.target.value); }} autoComplete="name" required data-testid="change_name_field" onKeyDown={async e => { if (e.key === 'Enter' && currentName && currentName.trim().length > 0 && currentName !== localPeerName) { e.preventDefault(); if (isMobile) { return; } changeName(); } }} /> {isMobile ? null : ( )}
); };