Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(ios): Make Bridge webView first responder #7753

Merged
merged 7 commits into from
Nov 21, 2024
Merged

fix(ios): Make Bridge webView first responder #7753

merged 7 commits into from
Nov 21, 2024

Conversation

theproducer
Copy link
Contributor

Fixes a focus issue (reproduction) caused when the webView is not the first responder. CAPBridgeViewController's self.becomeFirstResponder() was being called during viewDidLoad, before the view's window is set, which had no effect.

@theproducer theproducer changed the title fix(ios): make webView first responder fix(ios): Make Bridge webView first responder Nov 7, 2024
Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using self.webView?.becomeFirstResponder() in the same line were self.becomeFirstResponder() was also seems to work fine without the addition of the viewDidAppear override.

Rethinking this comment, the viewDidAppear method will be called in apps that embed the CAPBridgeViewController.swift whenever it appears, so putting the line there will make the WebView to regain focus, so looks like a better place than viewDidLoad.

@Steven0351 thoughts?

@jcesarmobile
Copy link
Member

Just remembered this initialFocus configuration option we added for Android, maybe we should add it for iOS too?

#5579

@markemer
Copy link
Member

Using self.webView?.becomeFirstResponder() in the same line were self.becomeFirstResponder() was also seems to work fine without the addition of the viewDidAppear override.

Rethinking this comment, the viewDidAppear method will be called in apps that embed the CAPBridgeViewController.swift whenever it appears, so putting the line there will make the WebView to regain focus, so looks like a better place than viewDidLoad.

@Steven0351 thoughts?

Yeah - viewDidAppear is probably better - but, I don't want to break Portal, et. al.

@Steven0351
Copy link
Contributor

Steven0351 commented Nov 13, 2024

Using self.webView?.becomeFirstResponder() in the same line were self.becomeFirstResponder() was also seems to work fine without the addition of the viewDidAppear override.
Rethinking this comment, the viewDidAppear method will be called in apps that embed the CAPBridgeViewController.swift whenever it appears, so putting the line there will make the WebView to regain focus, so looks like a better place than viewDidLoad.
@Steven0351 thoughts?

Yeah - viewDidAppear is probably better - but, I don't want to break Portal, et. al.

Nothing in here would affect Portals at all, so it's all good 👍, +1 for viewDidAppear

@jcesarmobile
Copy link
Member

jcesarmobile commented Nov 14, 2024

Not portals but embedded Capacitor, not sure what his name is nowadays.

I think this should be behind a initialFocus configuration option like on Android and also make a common initialFocus configuration option for both platforms as we do for some other settings so can be set globally or per platform, but the common one could be kept out of this PR since this is about iOS.

@theproducer theproducer merged commit 77e4668 into main Nov 21, 2024
6 checks passed
@theproducer theproducer deleted the RDMR-318 branch November 21, 2024 18:43
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants