66 */
77'use strict' ;
88
9+ var Platform = require ( 'Platform' ) ;
910var React = require ( 'React' ) ;
11+ var RCTUIManager = require ( 'NativeModules' ) . UIManager ;
1012var StyleSheet = require ( 'StyleSheet' ) ;
1113var View = require ( 'View' ) ;
1214
@@ -72,7 +74,15 @@ var Portal = React.createClass({
7274 return [ ] ;
7375 }
7476 return _portalRef . _getOpenModals ( ) ;
75- }
77+ } ,
78+
79+ notifyAccessibilityService : function ( ) {
80+ if ( ! _portalRef ) {
81+ console . error ( 'Calling closeModal but no Portal has been rendered.' ) ;
82+ return ;
83+ }
84+ _portalRef . _notifyAccessibilityService ( ) ;
85+ } ,
7686 } ,
7787
7888 getInitialState : function ( ) {
@@ -106,6 +116,20 @@ var Portal = React.createClass({
106116 return Object . keys ( this . state . modals ) ;
107117 } ,
108118
119+ _notifyAccessibilityService : function ( ) {
120+ if ( Platform . OS === 'android' ) {
121+ // We need to send accessibility event in a new batch, as otherwise
122+ // TextViews have no text set at the moment of populating event.
123+ setTimeout ( ( ) => {
124+ if ( this . _getOpenModals ( ) . length > 0 ) {
125+ RCTUIManager . sendAccessibilityEvent (
126+ React . findNodeHandle ( this ) ,
127+ RCTUIManager . AccessibilityEventTypes . typeWindowStateChanged ) ;
128+ }
129+ } , 0 ) ;
130+ }
131+ } ,
132+
109133 render : function ( ) {
110134 _portalRef = this ;
111135 if ( ! this . state . modals ) {
@@ -119,7 +143,9 @@ var Portal = React.createClass({
119143 return null ;
120144 }
121145 return (
122- < View style = { styles . modalsContainer } >
146+ < View
147+ style = { styles . modalsContainer }
148+ importantForAccessibility = "yes" >
123149 { modals }
124150 </ View >
125151 ) ;
0 commit comments