iPhoneNumberField icon indicating copy to clipboard operation
iPhoneNumberField copied to clipboard

Long phone number causes iPhoneNumberField to extend off screen

Open mywristbands opened this issue 3 years ago • 0 comments

When I enter a really long phone number into the iPhoneNumberField, it causes the field to extend off the screen:

Screen Shot 2021-10-01 at 6 31 24 PM

I looked into this issue, and there's an easy fix (src):

public func makeUIView(context: UIViewRepresentableContext<Self>) -> PhoneNumberTextField {
    let uiView = UIViewType()
    
    // Add the line below
    uiView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
    ...
}

Now the field behaves like it's supposed to (you can see the 9 on the left side is now partially cut off since the field's contents are now scrolling horizontally):

Screen Shot 2021-10-01 at 6 39 16 PM

Could someone implement this bug fix? I'd be happy to do it myself if I'm given permission to contribute.

mywristbands avatar Oct 02 '21 01:10 mywristbands