@@ -47,15 +47,15 @@ export const SwitchBase = ({
4747 const theme = useContext ( ThemeContext ) ;
4848 const [ isPressed , setIsPressed ] = React . useState ( false ) ;
4949 const isRadio = component === 'radio' ;
50- const switchSize = component === 'checkbox' ? checkboxSize : radioSize ;
50+ const switchSize = ! isRadio ? checkboxSize : radioSize ;
5151 const boxSize = variant === 'flat' ? switchSize - 4 : switchSize ;
5252 const borderRadius = isRadio ? boxSize / 2 : 0 ;
5353
54+ const checked = status === 'checked' ;
55+
5456 const renderCheckmark = ( ) => {
55- if ( status === 'checked' ) {
56- return component === 'checkbox' ? (
57- < CheckmarkIcon disabled = { disabled } />
58- ) : (
57+ if ( checked ) {
58+ return isRadio ? (
5959 < View
6060 style = { {
6161 borderRadius : 6 ,
@@ -66,6 +66,8 @@ export const SwitchBase = ({
6666 : theme . checkmark ,
6767 } }
6868 />
69+ ) : (
70+ < CheckmarkIcon disabled = { disabled } />
6971 ) ;
7072 }
7173 if ( status === 'indeterminate' ) {
@@ -97,6 +99,13 @@ export const SwitchBase = ({
9799 return disabled ? theme . material : theme . canvas ;
98100 } ;
99101
102+ const getAccessibilityComponentType = ( ) => {
103+ if ( isRadio ) {
104+ return checked ? 'radiobutton_checked' : 'radiobutton_unchecked' ;
105+ }
106+ return 'button' ;
107+ } ;
108+
100109 return (
101110 < TouchableHighlight
102111 style = { [ styles . wrapper ] }
@@ -107,13 +116,14 @@ export const SwitchBase = ({
107116 onShowUnderlay = { ( ) => setIsPressed ( true ) }
108117 // TODO: check if those accessibility properties are correct
109118 accessibilityTraits = { disabled ? [ 'button' , 'disabled' ] : 'button' }
110- accessibilityComponentType = 'button'
119+ accessibilityComponentType = { getAccessibilityComponentType ( ) }
111120 accessibilityRole = { component }
112- accessibilityState = { { disabled, checked : status === 'checked' } }
121+ accessibilityState = { { disabled, checked } }
122+ accessibilityLiveRegion = 'polite'
113123 underlayColor = 'none'
114124 { ...rest }
115125 >
116- < View style = { [ styles . content , style ] } pointerEvents = 'none' >
126+ < View style = { [ styles . content , style ] } >
117127 < View
118128 style = { [
119129 styles . switchSymbol ,
0 commit comments