material-components-ios icon indicating copy to clipboard operation
material-components-ios copied to clipboard

[TextControls]Truncated MDCOutlinedTextField labels

Open nguyetv75 opened this issue 4 years ago • 9 comments

I've encountered issues where some textfield floating labels are truncated. The placeholder text is also truncated. Is this a known issue? I've also tested on newer devices running on iOS14 and have also seen this issue. The ellipsis issue does not always happens, sometimes it happens on the floating labels and then sometimes it happens on the placeholder label.

I'm testing on iPhone 7 plus simulator iOS 12 MaterialComponents v123.0.0

iPhone 7 Plus iOS 12 Screen Shot 2021-02-26 at 4 15 48 PM

iPhone 8 Plus iOS 14 Screen Shot 2021-02-26 at 4 15 31 PM

nguyetv75 avatar Feb 26 '21 20:02 nguyetv75

This is not a known issue! Thanks for filing. Are there any specific steps to reproduce or code samples that you can provide to help with debugging?

andrewoverton avatar Mar 01 '21 17:03 andrewoverton

Here's a sample code that I used to render the username/password fields

textfield.label.text = label textfield.tintColor = .lightGray textfield.setTextColor(color, for: .normal) textfield.setTextColor(color, for: .editing) textfield.setOutlineColor(outlineColor!, for: .normal) textfield.setOutlineColor(outlineColor!, for: .editing) textfield.setFloatingLabelColor(color, for: .editing) textfield.sizeToFit()

Testing using iOS 12 seems to always truncate the placeholder and floating label. When I test using a device on iOS 14, this only happens sometimes.

nguyetv75 avatar Mar 01 '21 17:03 nguyetv75

Hi @nguyetv75, thanks for the sample code. Does doing textField.label.lineBreakStrategy = .byClipping fix the issue by any chance?

andrewoverton avatar Mar 03 '21 21:03 andrewoverton

I guess it fixed the truncation issue but then it causes a different issue. See the attached screenshot below. Screen Shot 2021-03-03 at 4 00 56 PM

nguyetv75 avatar Mar 03 '21 22:03 nguyetv75

anyone able to solve this? i am also facing this issue on ios 12

GManShen avatar Aug 26 '21 14:08 GManShen

Hello, I believe this bug was fixed in https://github.com/material-components/material-components-ios/commit/02cf9d713ef6f176e04329c4540f0af2acc86caa, but I don't think there's been a release since then. You could pin to develop and get the latest changes that way though!

andrewoverton avatar Aug 26 '21 14:08 andrewoverton

it crashes with NSInvalidArgumentException if i include the above fixes.

GManShen avatar Aug 26 '21 18:08 GManShen

Well , i found the issue, maybe helpful for someone, on ios 12 and below you need to set cliptobounds to NO, which seem to fix the issue.

GManShen avatar Aug 27 '21 06:08 GManShen

Interesting, when you use the version on develop it crashes on iOS 12 and below? Do you know where exactly it crashes? Do you have any steps to reproduce?

andrewoverton avatar Aug 31 '21 15:08 andrewoverton