Skip to content

Commit

Permalink
fix(iOS): enable/disable keyboard shortcuts only on iOS (#48518)
Browse files Browse the repository at this point in the history
Summary:
This PR guards code that enables/disables keyboard shortcuts only on iOS (iPadOS included).

![CleanShot 2025-01-07 at 14 49 36@2x](https://github.com/user-attachments/assets/cba4e19c-5a52-4874-94cf-a3e18112c8a3)

## Changelog:

[IOS] [FIXED] - enable/disable keyboard shortcuts only on iOS

Pull Request resolved: #48518

Test Plan: CI Green

Reviewed By: rshest

Differential Revision: D67900442

Pulled By: javache

fbshipit-source-id: 249a7c3124d02d2c30303d218e2b26e987ae1f0f
  • Loading branch information
okwasniewski authored and facebook-github-bot committed Jan 7, 2025
1 parent 38c46fe commit 8b0af45
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ - (void)textDidChange

- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
{
#if TARGET_OS_IOS
// Initialize the initial values only once
if (_initialValueLeadingBarButtonGroups == nil) {
// Capture initial values of leading and trailing button groups
Expand All @@ -154,6 +155,7 @@ - (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
self.inputAssistantItem.trailingBarButtonGroups = _initialValueTrailingBarButtonGroups;
}
_disableKeyboardShortcuts = disableKeyboardShortcuts;
#endif
}

#pragma mark - Overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ - (void)setInputAccessoryViewButtonLabel:(NSString *)inputAccessoryViewButtonLab

- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
{
#if TARGET_OS_IOS
// Initialize the initial values only once
if (_initialValueLeadingBarButtonGroups == nil) {
// Capture initial values of leading and trailing button groups
Expand All @@ -415,6 +416,7 @@ - (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
self.backedTextInputView.inputAssistantItem.leadingBarButtonGroups = _initialValueLeadingBarButtonGroups;
self.backedTextInputView.inputAssistantItem.trailingBarButtonGroups = _initialValueTrailingBarButtonGroups;
}
#endif
}

#pragma mark - RCTBackedTextInputDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ - (void)setSecureTextEntry:(BOOL)secureTextEntry

- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
{
#if TARGET_OS_IOS
// Initialize the initial values only once
if (_initialValueLeadingBarButtonGroups == nil) {
// Capture initial values of leading and trailing button groups
Expand All @@ -137,6 +138,7 @@ - (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
self.inputAssistantItem.trailingBarButtonGroups = _initialValueTrailingBarButtonGroups;
}
_disableKeyboardShortcuts = disableKeyboardShortcuts;
#endif
}

#pragma mark - Placeholder
Expand Down

0 comments on commit 8b0af45

Please sign in to comment.