Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 07501fc

Browse files
committed
hide FlutterTextInputView from accessibility
1 parent 78d774b commit 07501fc

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,28 @@ - (void)deleteBackward {
517517

518518
@end
519519

520+
/**
521+
* Hides `FlutterTextInputView` from iOS accessibility system so it
522+
* does not show up twice, once where it is in the `UIView` hierarchy,
523+
* and a second time as part of the `SemanticsObject` hierarchy.
524+
*/
525+
@interface FlutterTextInputViewAccessibilityHider : UIView {
526+
}
527+
528+
@end
529+
530+
@implementation FlutterTextInputViewAccessibilityHider {
531+
}
532+
533+
- (BOOL)accessibilityElementsHidden {
534+
return YES;
535+
}
536+
537+
@end
538+
520539
@implementation FlutterTextInputPlugin {
521540
FlutterTextInputView* _view;
541+
FlutterTextInputViewAccessibilityHider* _inputHider;
522542
}
523543

524544
@synthesize textInputDelegate = _textInputDelegate;
@@ -528,6 +548,7 @@ - (instancetype)init {
528548

529549
if (self) {
530550
_view = [[FlutterTextInputView alloc] init];
551+
_inputHider = [[FlutterTextInputViewAccessibilityHider alloc] init];
531552
}
532553

533554
return self;
@@ -536,6 +557,7 @@ - (instancetype)init {
536557
- (void)dealloc {
537558
[self hideTextInput];
538559
[_view release];
560+
[_inputHider release];
539561

540562
[super dealloc];
541563
}
@@ -572,13 +594,15 @@ - (void)showTextInput {
572594
@"The application must have a key window since the keyboard client "
573595
@"must be part of the responder chain to function");
574596
_view.textInputDelegate = _textInputDelegate;
575-
[[UIApplication sharedApplication].keyWindow addSubview:_view];
597+
[_inputHider addSubview:_view];
598+
[[UIApplication sharedApplication].keyWindow addSubview:_inputHider];
576599
[_view becomeFirstResponder];
577600
}
578601

579602
- (void)hideTextInput {
580603
[_view resignFirstResponder];
581604
[_view removeFromSuperview];
605+
[_inputHider removeFromSuperview];
582606
}
583607

584608
- (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configuration {

shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_TEXT_ENTRY_H_
77

88
/**
9-
* An implementation of `UITextInput` used for text fields that do not currently have input focus.
9+
* An implementation of `UITextInput` used for text fields that do not currently
10+
* have input focus.
1011
*
1112
* This class is used by `TextInputSemanticsObject`.
1213
*/
@@ -22,10 +23,12 @@
2223
@end
2324

2425
/**
25-
* An implementation of `SemanticsObject` specialized for expressing text fields.
26+
* An implementation of `SemanticsObject` specialized for expressing text
27+
* fields.
2628
*
27-
* Delegates to `FlutterTextInputView` when the object corresponds to a text field
28-
* that currently owns input focus. Delegates to `FlutterInactiveTextInput` otherwise.
29+
* Delegates to `FlutterTextInputView` when the object corresponds to a text
30+
* field that currently owns input focus. Delegates to
31+
* `FlutterInactiveTextInput` otherwise.
2932
*/
3033
@interface TextInputSemanticsObject : SemanticsObject<UITextInput>
3134
@end

shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ - (void)deleteBackward {
165165

166166
@end
167167

168-
169168
@implementation TextInputSemanticsObject {
170169
FlutterInactiveTextInput* _inactive_text_input;
171170
}

0 commit comments

Comments
 (0)