Skip to content

Commit aa3ba35

Browse files
committed
fix(clerk-js): Use ch to calculate phone input padding
1 parent 8ab543a commit aa3ba35

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/clerk-js/src/ui/elements/PhoneInput/PhoneInput.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const PhoneInput = (props: PhoneInputProps) => {
3939
const selectedCountryOption = React.useMemo(() => {
4040
return countryOptions.find(o => o.country.iso === selectedIso) || countryOptions[0];
4141
}, [selectedIso]);
42-
const dynamicPadding = selectedCountryOption.country.code.length * 5; // this is to calculate the padding of the input field depending the length of country code
4342

4443
React.useEffect(callOnChangeProp, [cleanPhoneNumber]);
4544

@@ -122,7 +121,9 @@ export const PhoneInput = (props: PhoneInputProps) => {
122121
onChange={handlePhoneNumberChange}
123122
maxLength={25}
124123
type='tel'
125-
sx={theme => ({ paddingLeft: `calc(${theme.space.$20} + ${dynamicPadding}px)` })}
124+
sx={theme => ({
125+
paddingLeft: `calc(${theme.space.$20} + ${selectedCountryOption.country.code.length + 1}ch)`,
126+
})}
126127
ref={phoneInputRef}
127128
{...rest}
128129
/>

0 commit comments

Comments
 (0)