Skip to content

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

@rahulVermaSimpplr

Description

@rahulVermaSimpplr

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions