@@ -517,8 +517,28 @@ - (void)deleteBackward {
517
517
518
518
@end
519
519
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
+
520
539
@implementation FlutterTextInputPlugin {
521
540
FlutterTextInputView* _view;
541
+ FlutterTextInputViewAccessibilityHider* _inputHider;
522
542
}
523
543
524
544
@synthesize textInputDelegate = _textInputDelegate;
@@ -528,6 +548,7 @@ - (instancetype)init {
528
548
529
549
if (self) {
530
550
_view = [[FlutterTextInputView alloc ] init ];
551
+ _inputHider = [[FlutterTextInputViewAccessibilityHider alloc ] init ];
531
552
}
532
553
533
554
return self;
@@ -536,6 +557,7 @@ - (instancetype)init {
536
557
- (void )dealloc {
537
558
[self hideTextInput ];
538
559
[_view release ];
560
+ [_inputHider release ];
539
561
540
562
[super dealloc ];
541
563
}
@@ -572,13 +594,15 @@ - (void)showTextInput {
572
594
@" The application must have a key window since the keyboard client "
573
595
@" must be part of the responder chain to function" );
574
596
_view.textInputDelegate = _textInputDelegate;
575
- [[UIApplication sharedApplication ].keyWindow addSubview: _view];
597
+ [_inputHider addSubview: _view];
598
+ [[UIApplication sharedApplication ].keyWindow addSubview: _inputHider];
576
599
[_view becomeFirstResponder ];
577
600
}
578
601
579
602
- (void )hideTextInput {
580
603
[_view resignFirstResponder ];
581
604
[_view removeFromSuperview ];
605
+ [_inputHider removeFromSuperview ];
582
606
}
583
607
584
608
- (void )setTextInputClient : (int )client withConfiguration : (NSDictionary *)configuration {
0 commit comments