Skip to content

refactor: guard KeyboardLayoutGuide path through config (instead of direct checks)#1517

Merged
kirillzyusko merged 1 commit into
mainfrom
refactor/guard-keyboard-layout-guide-path-via-config
Jun 26, 2026
Merged

refactor: guard KeyboardLayoutGuide path through config (instead of direct checks)#1517
kirillzyusko merged 1 commit into
mainfrom
refactor/guard-keyboard-layout-guide-path-via-config

Conversation

@kirillzyusko

@kirillzyusko kirillzyusko commented Jun 25, 2026

Copy link
Copy Markdown
Owner

📜 Description

Make configuration for KeyboardTrackingView.

💡 Motivation and Context

In 1.22.x I want to re-write the algorithm for tracking keyboard (yes, again) and switch back to legacy path (it looks like I found a better way of managing things and I can deliver better experience than KeyboardLayoutGuide).

But at the same time I don't want to drop the current code with KeyboardLayoutGuide. So I decided to hide it under feature flag. If users discover regressions - they can just toggle feature flag and restore old behavior.

Also in future if my method stops to work again I can also toggle feature flag and use modern path (when KeyboardLayoutGuide will be stable).

To achieve this I added KeyboardControllerConfiguration with usesKeyboardLayoutGuideTracking field. And repalced corresponding #available(iOS 26.0, *) condition to usesKeyboardLayoutGuideTracking field. Such code helps us:

  • reduce code fragmentation;
  • control things from one place;
  • simplify the codebase and maintenance in the future.

While refactoring it I also realised that we don't need to attach invisible KeyboardLayoutGuide on older iOS versions so I also guarded this code with usesKeyboardLayoutGuideTracking flag.

📢 Changelog

iOS

  • added KeyboardControllerConfiguration file;
  • guard KeyboardLayoutGuide code under usesKeyboardLayoutGuideTracking flag;

🤔 How Has This Been Tested?

Tested via e2e test.

📸 Screenshots (if appropriate):

Screenshot 2026-06-26 at 17 51 28

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Jun 25, 2026
@kirillzyusko kirillzyusko added 🍎 iOS iOS specific refactor You changed the code but it didn't affect functionality labels Jun 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📊 Package size report

Current size Target Size Difference
321567 bytes 321409 bytes 158 bytes 📈

@kirillzyusko kirillzyusko force-pushed the refactor/guard-keyboard-layout-guide-path-via-config branch from e377fcc to b6d4fec Compare June 26, 2026 14:24
@kirillzyusko kirillzyusko marked this pull request as ready for review June 26, 2026 15:51
@github-actions

Copy link
Copy Markdown
Contributor
  1. Guard Statement in attachToTopmostView Prevents Attachment on Older iOS
    Why: The guard statement in attachToTopmostView returns early if usesKeyboardLayoutGuideTracking is false, which skips attaching the view on older iOS versions where it's needed.
    Fix: Remove the guard statement to ensure attachment happens across all supported iOS versions.

  2. Incorrect View Type Determination Based on Configuration
    Why: The view property uses the configuration to choose between self and keyboardView, risking incorrect selection if the configuration is misused or has bugs.
    Fix: Replace the condition with a direct check for iOS version 26 or higher using #available(iOS 26.0, *).

@objc var view: UIView? {
  if #available(iOS 26.0, *) {
    return self
  } else {
    return keyboardView
  }
}

This ensures the correct view is selected based on actual iOS version compatibility rather than a potentially flawed configuration setting.

@kirillzyusko kirillzyusko merged commit 918254a into main Jun 26, 2026
19 checks passed
@kirillzyusko kirillzyusko deleted the refactor/guard-keyboard-layout-guide-path-via-config branch June 26, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍎 iOS iOS specific refactor You changed the code but it didn't affect functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant