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

TextView looses focus after first character entry #61

Open
justdan0227 opened this issue Aug 27, 2021 · 6 comments
Open

TextView looses focus after first character entry #61

justdan0227 opened this issue Aug 27, 2021 · 6 comments

Comments

@justdan0227
Copy link

justdan0227 commented Aug 27, 2021

I've noticed that if you use a TextView, that when you put the cursor in the field and start to type, that after the first character focus is lost. If you click the field again you can then continue typing. It's only on the first character the first time.
I notice that if you go into the example, and try the textview this happens. What is odd is that if you hit clear at the start then the field works correctly. Its only when it has an initial value in it and you start typing that the focus is lost.

Thoughts?

@neoneye
Copy link
Owner

neoneye commented Aug 27, 2021

What is your iOS version?

Never seen this behavior iirc.

@justdan0227
Copy link
Author

ios 15.

So I found that inside of TextViewCell.swift that that lines:

	public func updateValue() {
		let s = textView.text ?? ""
		let hasText = !s.isEmpty
		placeholderLabel.isHidden = hasText

		let tableView: UITableView? = form_tableView()
		if let tv = tableView {
			setNeedsLayout()
			tv.beginUpdates()
			tv.endUpdates()
		}
	}

that if I comment this out it works?

// let tableView: UITableView? = form_tableView()
// if let tv = tableView {
// setNeedsLayout()
// tv.beginUpdates()
// tv.endUpdates()
// }

@justdan0227
Copy link
Author

The keyboard is getting dismissed for some reason (turn on soft keyboard in the simulator, and you'll see it get dismissed the first time)

@neoneye
Copy link
Owner

neoneye commented Aug 27, 2021

This seems like a good solution.

Unfortunately I can't remember why I put the code there to begin with.

@justdan0227
Copy link
Author

So I've been running with this for several months now and can not tell that it breaks anything. Can we get that put into the master branch?

@neoneye
Copy link
Owner

neoneye commented Nov 22, 2021

Unfortunately commenting out the code breaks the existing behavior, and places the cursor in the left-side of the screen, barely visible.

Left side: code is commented out.

Right side: the original code.

Screen Shot 2021-11-22 at 17 02 42

PRs are welcome.

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

No branches or pull requests

2 participants