Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(mobile/ios): drop the second hiding of the keyboard bar
Elian Dorane31a92cc4085
diff --git a/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.tsx b/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.tsxindex 020535d613..3f329084c9 100644--- a/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.tsx+++ b/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.tsx@@ -13,8 +13,8 @@ import ActionButton from "../react/ActionButton";* corner, just above the keyboard, while `RootContainer` marks the keyboard as open with* `virtual-keyboard-opened`. While `MobileEditorToolbar` is shown, which it is while its editor has* the focus, the toolbar carries the button instead (see `hide_keyboard_button.css`).- * In the iOS app, blurring also hides the keyboard's input accessory bar (see- * `ViewController.hideKeyboardInputAccessoryView()`).+ * In the iOS app, the keyboard has no _Done_ button of its own, as `@capacitor/keyboard` hides the+ * bar that holds it.*/export default function HideKeyboardButton() {const containerRef = useRef<HTMLDivElement>(null);diff --git a/apps/mobile/ios/App/App/ViewController.swift b/apps/mobile/ios/App/App/ViewController.swiftindex d3a89b28b4..2f9039fb5d 100644--- a/apps/mobile/ios/App/App/ViewController.swift+++ b/apps/mobile/ios/App/App/ViewController.swift@@ -18,7 +18,6 @@ class ViewController: CAPBridgeViewController {override func viewDidLoad() {super.viewDidLoad()- hideKeyboardInputAccessoryView()enableInteractiveKeyboardDismiss()observeKeyboard()}@@ -32,7 +31,7 @@ class ViewController: CAPBridgeViewController {// Routes local API requests on capacitor:// to TriliumRequestBridge. Capacitor registers its// WebViewAssetHandler before this hook runs, and WebKit raises NSInvalidArgumentException on// a second handler for the same scheme, so the registered instance is re-typed to the- // TriliumAssetHandler subclass instead (the same technique as hideKeyboardInputAccessoryView).+ // TriliumAssetHandler subclass instead.override func webView(with frame: CGRect, configuration: WKWebViewConfiguration) -> WKWebView {if let assetHandler = configuration.urlSchemeHandler(forURLScheme: "capacitor") as? WebViewAssetHandler {object_setClass(assetHandler, TriliumAssetHandler.self)@@ -157,9 +156,9 @@ class ViewController: CAPBridgeViewController {self.webView?.evaluateJavaScript(js, completionHandler: nil)}- // Because we hide iOS's input accessory bar (which contains the Done- // button), the user would otherwise have no native way to dismiss the- // keyboard. Enable interactive swipe-down dismissal on the web view's+ // Because @capacitor/keyboard hides iOS's input accessory bar (which+ // contains the Done button), the user would otherwise have no native way+ // to dismiss the keyboard. Enable interactive swipe-down dismissal on the web view's// scroll view — this is the same gesture Messages, Mail, and most// first-party iOS apps use. Dragging the content area downward follows// the finger and hides the keyboard when it reaches the bottom.@@ -167,43 +166,4 @@ class ViewController: CAPBridgeViewController {guard let webView = self.webView else { return }webView.scrollView.keyboardDismissMode = .interactive}-- // The iOS keyboard shows a native "input accessory view" above the- // software keyboard — the row with Prev/Next arrows and the Done button.- // Capacitor's `Keyboard.resize: native` resizes the web view above the- // keyboard itself, but the accessory view sits on top of that and- // overlaps the editor toolbar. We hide it by dynamically subclassing- // WebKit's internal WKContentView and overriding `inputAccessoryView`- // to return nil. This is the canonical way to remove it in WKWebView- // apps and doesn't depend on the @capacitor/keyboard JS bridge being- // reachable at call time.- private func hideKeyboardInputAccessoryView() {- guard let webView = self.webView else { return }- guard let contentView = webView.scrollView.subviews.first(where: {- String(describing: type(of: $0)).contains("WKContent")- }) else { return }-- let originalClass: AnyClass = type(of: contentView)- let subclassName = "TriliumNoAccessoryView_\(NSStringFromClass(originalClass))"-- // If we've already generated the subclass on a previous run, reuse it.- if let existing = NSClassFromString(subclassName) {- object_setClass(contentView, existing)- return- }-- guard let subclass = objc_allocateClassPair(originalClass, subclassName, 0) else {- return- }-- let selector = NSSelectorFromString("inputAccessoryView")- if let method = class_getInstanceMethod(UIView.self, selector) {- let block: @convention(block) (AnyObject) -> UIView? = { _ in nil }- let implementation = imp_implementationWithBlock(block)- class_addMethod(subclass, selector, implementation, method_getTypeEncoding(method))- }-- objc_registerClassPair(subclass)- object_setClass(contentView, subclass)- }}