Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 19, 2025

The toolbar was flashing when navigating back from a navigation controller while the keyboard remained visible. This occurred because reloadInputViews() (Swift) and addToolbarIfRequired (Objective-C) were being called unnecessarily during navigation transitions, causing the toolbar to be recreated and creating a visual flash.

Root Cause

The issue was in the scroll animation completion blocks in both implementations:

Swift version:

}, completion: {
    if scrollView is UITableView || scrollView is UICollectionView {
        textInputView.reloadInputViews() // <- Caused flash during navigation
    }
})

Objective-C version:

} completion:^(BOOL finished){
    if ([superScrollView isKindOfClass:[UITableView class]] || [superScrollView isKindOfClass:[UICollectionView class]]) {
        if ([strongSelf privateIsEnableAutoToolbar] == YES) {
            [strongSelf addToolbarIfRequired]; // <- Caused flash during navigation
        }
    }
}];

Solution

Added checks to detect when interactive navigation gestures are active and skip toolbar recreation during those periods:

  • Swift: Uses existing activeConfiguration.rootControllerConfiguration.isInteractiveGestureActive
  • Objective-C: Checks interactivePopGestureRecognizer.state for .began and .changed states

Testing

To reproduce and verify the fix:

  1. Focus on a text field with toolbar enabled (e.g., in SearchViewController)
  2. Navigate to next screen using navigationController.pushViewController
  3. Navigate back via swipe gesture or back button while keyboard is showing
  4. Toolbar should remain stable without flashing

Impact

  • Eliminates visual toolbar flash during navigation transitions
  • Preserves all existing keyboard management functionality
  • Uses existing gesture detection mechanisms
  • Minimal code changes with no breaking changes

Fixes #2102.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…esture state

Co-authored-by: hackiftekhar <3831495+hackiftekhar@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] The toolbar flashes when navigating back from navigation controller Fix toolbar flashing during navigation back with keyboard showing Sep 19, 2025
@Copilot Copilot AI requested a review from hackiftekhar September 19, 2025 09:44
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

Successfully merging this pull request may close these issues.

The toolbar flashes when navigating back from navigation controller

2 participants