New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ORKTextField] Coherent placeholder handling #445
[ORKTextField] Coherent placeholder handling #445
Conversation
Did we want to extend this same functionality to the multiline textfields? For example, check out the Message form item under Mini Form in ORKTest. |
@umerkhan-apple: I'll look into this in the following days. |
@rsanchezsaez So did you get a chance to look at multiline textfields? Do we want to extend this functionality to them, or should we just leave it to single line textfields? |
Hey Umer, Sorry, I missed the GitHub notification earlier. I agree that the placeholder on text views (multiline text fields) should behave like the text field one. I'm looking into this. |
@umerkhan-apple: Done, I have implemented the same placeholder behavior for |
@rsanchezsaez Awesome, I will test the changes shortly. |
[[NSNotificationCenter defaultCenter] addObserver:self | ||
selector:@selector(updateAppearance) | ||
name:UIContentSizeCategoryDidChangeNotification | ||
object:nil]; | ||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewTextDidChange:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move selector argument onto a new line just to stay consistent.
Adding the placeholder to the First, I tried using a plain So I settled to adding a non-interactive |
|
||
[self updateAppearance]; | ||
} | ||
|
||
- (void)layoutSubviews { | ||
[super layoutSubviews]; | ||
// Setting the frame directly causes a layout error on a form step (it looks like an iOS bug, as setting the frame should produce the same effect as settings the bounds and the center) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: settings -> setting
@rsanchezsaez I agree that this is a bit of a tricky implementation. I will look into finding a cleaner approach if possible. Currently, the framework is crashing if I change orientation from Portrait to Landscape inside Console log
Tested on iPhone 5 and iPhone 6S. |
I've fixed the crash, that was an unrelated silly mistake on my end. Let me know if you come up with an alternate solution for the text view placeholder. |
@@ -185,7 +184,7 @@ - (void)ork_setSuffix:(NSString *)suffix withColor:(UIColor *)color { | |||
if (suffix.length == 0) { | |||
return; | |||
} | |||
_suffixLabel = [self ork_createTextLabelWithTextColor:color ?: [UIColor grayColor]]; | |||
_suffixLabel = [self ork_createTextLabelWithTextColor:(color ?: [UIColor ork_midGrayTintColor])]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intention of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This color is sometimes used for the unit suffix label when editing an empty ORKTextFieldView
with no placeholder. You can see this if you revert this change, tap on the first text field of the first step on Mini Form, tap on the second field, and then tap on the first field again (the unit suffix label turns darker).
ork_midGrayTintColor
is used as the color in all other placeholder
s and unit suffix instances, so I figured it should be used here too.
But maybe we should also review the actual color-chosing logic, because it's weird that this color only gets used the second time you tap on the field but not the first one.
I'll later look into the alignment of the text view. |
@rsanchezsaez After internal discussion, we have come to the following conclusion:
|
Ok. But why do that for first the case? Don't you think keeping the placeholder until some text is typed is more coherent and consistent? |
The main reason for that conclusion was that having two placeholders seemed untidy and slightly confusing for the user. |
But, in my opinion, the user perception is that, when editing an empty unit-suffixed text field, the unit label becomes part of the placeholder text and then, when they start typing, the "long placeholder" transforms to show only the unit suffix. I think this worked well after reducing the placeholder <> unit separation (see the before/after screenshots above). Don't you think? If you remain unconvinced let me know and I'll update it to the behavior you requested. :) |
@rsanchezsaez I think the original set a more clear distinction between And when the textfield become active, showing both of them makes the field a little noisy. |
…ing extra unneeded padding between the placeholder and the unit
…eholder # Conflicts: # ResearchKit/Common/ORKTextFieldView.m
To reproduce, tap on an empty field with unit label and no placeholder (first form item of first step in ORKTest's Miniform).
…ldView This creates a non-interactive 'UITextView' for displaying the placeholder at the exact same position as the 'ORKAnswerTextView' text. It improves encapsulation, the 'ORKAnswerTextView' class handles the placeholder internally. Also: some minor naming convention improvenets in 'ORKTextFieldView'.
…ld empty without triggering answer validity checking This fixes a regression. It restores the behavior in which you are allowed to edit a different text field in a form if you leave the current text field blank. E.g., on ORKTest's 'Mini Form', tapping on the first cell text field and then tapping on second cell text field without having written anything should not trigger the alert.
99047fe
to
2289abf
Compare
I have updated this PR against the latest
I also fixed a regression in which the user was being prevented leaving a form text field blank (a validation alert was being shown, you can try in Let me know if you want additional changes. I think the animation glitch and the suffix color mismatch fixes are worthwhile improvements as well. |
The text frame sometimes animated from left to right (e.g., in ORKTest's MiniForm, tap 4th text field, type any number and tap any other text field). Also remove needless period on latest placeholder text.
Also, the TextView misalign shown in the above comment screenshot no longer seems to be an issue. Maybe iOS 9.2 fixed it? I don't see any RK code change related to that. Please let me know if this is still a problem. |
R=ME:) @umerkhan-apple Can you take a look as well? |
@umerkhan-apple Get a chance to try this? |
…chezsaez-HomogeneousORKTextFieldView
@umerkhan-apple Ping? ;-) |
…extFieldView [ORKTextField] Coherent placeholder handling
This PR makes the handing of the placeholder in
ORKTextField
more similar to whatUITextField
does.It comprises of two changes:
UITextField
).Also reuses form item cells in
ORKStepViewController
so cells are not created twice when calculating their height.Before:
After: