Skip to content

Commit 8eb2f4a

Browse files
Merge pull request #4485 from OneCommunityGlobal/venkataramanan_fix_phone_icon_alignment
Venkataramanan 🔥 Phone icon alignment in user profile page
2 parents e945f09 + eff46d0 commit 8eb2f4a

1 file changed

Lines changed: 46 additions & 39 deletions

File tree

src/components/UserProfile/BasicInformationTab/BasicInformationTab.jsx

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -334,64 +334,71 @@ export const formatPhoneNumber = str => {
334334
};
335335

336336
export const Phone = props => {
337-
const { userProfile, setUserProfile, handleUserProfile, canEdit, desktopDisplay ,darkMode} = props;
337+
const { userProfile, setUserProfile, handleUserProfile, canEdit, desktopDisplay, darkMode } = props;
338338
const { phoneNumber, privacySettings } = userProfile;
339339
const phoneInputWrapperRef = useRef(null);
340+
340341
if (canEdit) {
341342
return (
342343
<>
343344
<Col md={desktopDisplay ? '6' : ''}>
344345
<FormGroup>
346+
{/* one toggle, same as Email */}
345347
<ToggleSwitch
346348
switchType="phone"
347349
id="phone"
348350
state={privacySettings?.phoneNumber}
349351
handleUserProfile={handleUserProfile}
350352
darkMode={darkMode}
351353
/>
352-
<PhoneInput
353-
buttonClass={`${darkMode ? 'bg-darkmode-liblack' : ''}`}
354-
inputClass={`phone-input-style ${darkMode ? 'bg-darkmode-liblack border-0 text-light' : ''}`}
355-
country={'us'}
356-
data-testid="ph-input-style"
357-
id="ph-input-style"
358-
value={phoneNumber}
359-
onChange={phoneNumber => {
360-
setUserProfile({ ...userProfile, phoneNumber: phoneNumber.trim() });
361-
}}
362-
/>
363-
<FontAwesomeIcon
364-
icon={faCopy}
365-
onClick={() => {
366-
const input = phoneInputWrapperRef.current?.querySelector('input');
367-
if (input) {
368-
navigator.clipboard.writeText(input.value);
369-
toast.success('Phone number copied!');
370-
}
371-
}}
372-
title="Copy phone number"
373-
style={{
374-
position: 'absolute',
375-
right: '12px',
376-
top: '50%',
377-
transform: 'translateY(-50%)',
378-
cursor: 'pointer',
379-
fontSize: '1rem',
380-
color: darkMode ? '#fff' : '#000',
381-
zIndex: 2,
382-
}}
383-
/>
384-
<ToggleSwitch
385-
switchType="phone"
386-
state={privacySettings?.phoneNumber}
387-
handleUserProfile={handleUserProfile}
388-
darkMode={darkMode}
389-
/>
354+
355+
{/* wrapper to position the copy icon correctly */}
356+
<div
357+
ref={phoneInputWrapperRef}
358+
style={{ position: 'relative', width: '100%' }}
359+
>
360+
<PhoneInput
361+
buttonClass={`${darkMode ? 'bg-darkmode-liblack' : ''}`}
362+
inputClass={`phone-input-style ${
363+
darkMode ? 'bg-darkmode-liblack border-0 text-light' : ''
364+
}`}
365+
country="us"
366+
data-testid="ph-input-style"
367+
id="ph-input-style"
368+
value={phoneNumber}
369+
onChange={value => {
370+
setUserProfile({ ...userProfile, phoneNumber: value.trim() });
371+
}}
372+
/>
373+
374+
<FontAwesomeIcon
375+
icon={faCopy}
376+
title="Copy phone number"
377+
onClick={() => {
378+
const input = phoneInputWrapperRef.current?.querySelector('input');
379+
if (input) {
380+
navigator.clipboard.writeText(input.value);
381+
toast.success('Phone number copied!');
382+
}
383+
}}
384+
style={{
385+
position: 'absolute',
386+
cursor: 'pointer',
387+
fontSize: '1rem',
388+
color: darkMode ? '#fff' : '#000',
389+
top: '50%',
390+
right: '10px',
391+
transform: 'translateY(-50%)',
392+
zIndex: 2,
393+
}}
394+
/>
395+
</div>
390396
</FormGroup>
391397
</Col>
392398
</>
393399
);
394400
}
401+
395402
return (
396403
<>
397404
{privacySettings?.phoneNumber && (

0 commit comments

Comments
 (0)