You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clicking on a Pressable with disabled={true} does not trigger it to go into a focused state, however clicking on it's children does.
Expected behavior
If the Pressable is disabled, the same behavior should be applied to it's children elements and tapping them should not cause the pressable's onFocus event to fire.
Steps to reproduce
Create a Pressable with a Text child
Set its disabled state to true, add onPress, onFocus, onBlur events to toggle the focused state of the Pressable.
Notice that tapping the Pressable does nor fire onPress or onFocus events, since the button is disabled, however tapping the Text element fires onFocus
In the source code of Pressable component, the disabled prop is assigned to aria-disabled.: return ( <View {...rest} {...pressEventHandlers} aria-disabled={disabled} onBlur={blurHandler} onContextMenu={contextMenuHandler} onFocus={focusHandler} onKeyDown={keyDownHandler} ref={setRef} style={[ disabled ? styles.disabled : styles.active, typeof style === 'function' ? style(interactionState) : style ]} tabIndex={_tabIndex} > {typeof children === 'function' ? children(interactionState) : children} </View> );
The difference between aria-disabled and disabled is:
• aria-disabled="true" is used only for accessibility tools (such as screen readers) to inform the user that the component is disabled and not interactive.
• disabled={true} will disable the component’s interactive functionality, preventing the user from performing actions like clicking or inputting, and it will also affect the component’s appearance (for example, the button might appear gray).
So, I think you should control the styles and behavior of disabled in your own project:
Is there an existing issue for this?
Describe the issue
Clicking on a
Pressable
withdisabled={true}
does not trigger it to go into a focused state, however clicking on it's children does.Expected behavior
If the Pressable is
disabled
, the same behavior should be applied to it's children elements and tapping them should not cause the pressable'sonFocus
event to fire.Steps to reproduce
true
, addonPress
,onFocus
,onBlur
events to toggle the focused state of the Pressable.onPress
oronFocus
events, since the button is disabled, however tapping the Text element firesonFocus
Test case
https://snack.expo.dev/@kristinetrona/tenacious-green-soda?platform=web
Additional comments
Example code:
See screen recording:
Screen.Recording.2025-01-24.at.12.14.24.mov
The text was updated successfully, but these errors were encountered: