IQKeyboardManager icon indicating copy to clipboard operation
IQKeyboardManager copied to clipboard

Wrong 'UITraitCollection.current.userInterfaceStyle' on pressing 'Done' button

Open rahulVermaSimpplr opened this issue 11 months ago • 1 comments

Describe the bug
The Done button (input accessory view) in the toolbar of UITextField returns an incorrect value for UITraitCollection.current.userInterfaceStyle. However, when tapping the default return button of the keyboard, the correct value is returned.

To Reproduce
Steps to reproduce the behavior:

  1. Just drop a UITextField on the storyboard and make its delegate to self controller.
  2. Confirm to delegate method - 'textFieldDidEndEditing' and put a print statement to print the 'UITraitCollection.current.userInterfaceStyle == .dark'.
  3. Change the device’s appearance (Light/Dark mode).
  4. Tap the UITextField to bring up the keyboard.
  5. Press the Done button in the toolbar.
  6. Observe the value of UITraitCollection.current.userInterfaceStyle.
  7. Now, tap the Return button on the keyboard instead.
  8. Compare the value of UITraitCollection.current.userInterfaceStyle.
    Expected behavior
    UITraitCollection.current.userInterfaceStyle should return the correct interface style (light or dark mode) when tapping the Done button, just as it does when tapping the default return button.

Screenshots

Versions

  • Xcode: (16.2)
  • Mac OS: (14.7)
  • Simulator/Device: (Simulator)
  • Simulator/Device Name: iPhone (15)

rahulVermaSimpplr avatar Feb 21 '25 06:02 rahulVermaSimpplr

Thanks for reporting this @rahulVermaSimpplr. I tested this with my demo and it looks to be working well for me. If you have any demo project with which you are able to reproduce the issue, please share it. Thanks

hackiftekhar avatar Jun 05 '25 13:06 hackiftekhar