Skip to content
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

Fixed symbols in the mask #6

Closed
razalur opened this issue Feb 20, 2017 · 3 comments
Closed

Fixed symbols in the mask #6

razalur opened this issue Feb 20, 2017 · 3 comments

Comments

@razalur
Copy link

razalur commented Feb 20, 2017

It will be great to have the ability of fixed symbols using.

For example I need the mask for the phone number: +7 (111) 111-11-11
So according to documentation I can to create mask for this case: +7([000])[000]-[00]-[00]
And that's alright. But I need the user can't clear fist two symbols (+7). So every time "+7" have to be always visible in the text field.

@taflanidi
Copy link
Collaborator

Hey @razalur
Thanks for your suggestion. I will come back with feedback a bit later this week, stay tuned!

@tikhonov-aleksandr
Copy link

any updates ?

@taflanidi
Copy link
Collaborator

@TikhonovAlexander hey there. @razalur might be interested, too.

Thanks for reminding me about this feature request. We actually had a short talk with two evangelists from Apple about having a non-editable text inside the text field.

TL;DR: We are not going to support this feature.

It doesn't violate HIG directly though it is a bad idea to restrict user control over the app and take over the decision-making. Native text fields do not behave like that, and iOS SDK already has a component for a static text — a UILabel.

You can't disable or greyout a native keyboard Backspace button, and non-clearable symbols will bring confusion, as the end user won't be able to determine whether it is a designed behaviour or a bug. "Why exactly my Backspace button doesn't work?" — and you can't give a clear hint.

From our library design perspective, it is obvious that the developer might put a "fixed" symbol in the middle of the line. But what do you expect to happen when the user starts to delete characters from the beginning of the line?

Even more questions arise when you decide to incorporate a UITextField Clear button.
Corresponding delegate method -textFieldShouldClear() will not allow you to partially clear your text field, it is meant to erase all the text. Overriding or extending clear button behaviour is an ambiguous design decision and thus a large responsibility for our library, because we will have to cover all the use cases. Some people (developers and users) will want the native clear button to wipe out all the text, somebody will expect all the "fixed" symbols to stay after clearing, and others will assume only the "fixed" prefix should stay and "fixed" chars in the middle of the line should be erased.

The only thing I could help you with is an advice to think through the goals you are aiming to achieve.
Don't fight the SDK as the SDK always wins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants