[fix] Prevent href navigation for disabled Pressables

Close #2299
This commit is contained in:
Mike
2022-06-08 10:33:18 +08:00
committed by Nicolas Gallagher
parent ae2ee87404
commit 094bd0efc5
5 changed files with 5 additions and 2 deletions

View File

@@ -32,7 +32,7 @@ exports[`components/Button prop "color" 1`] = `
exports[`components/Button prop "disabled" 1`] = `
<div
aria-disabled="true"
class="css-view-175oi2r r-transitionProperty-1i6wzkk r-userSelect-lrvibr r-borderRadius-1jkafct r-backgroundColor-11mpjr4"
class="css-view-175oi2r r-transitionProperty-1i6wzkk r-userSelect-lrvibr r-borderRadius-1jkafct r-backgroundColor-11mpjr4 r-pointerEvents-633pao"
role="button"
style="transition-duration: 0s;"
tabindex="-1"

View File

@@ -152,7 +152,7 @@ exports[`components/Pressable prop "accessibilityRole" value is set 1`] = `
exports[`components/Pressable prop "disabled" 1`] = `
<div
aria-disabled="true"
class="css-view-175oi2r"
class="css-view-175oi2r r-pointerEvents-633pao"
tabindex="-1"
/>
`;

View File

@@ -205,6 +205,7 @@ function Pressable(props: Props, forwardedRef): React.Node {
onContextMenu={contextMenuHandler}
onFocus={focusHandler}
onKeyDown={keyDownHandler}
pointerEvents={disabled ? 'none' : rest.pointerEvents}
ref={setRef}
style={[
!disabled && styles.root,

View File

@@ -167,6 +167,7 @@ function TouchableHighlight(props: Props, forwardedRef): React.Node {
{...pressEventHandlers}
accessibilityDisabled={disabled}
focusable={!disabled && focusable !== false}
pointerEvents={disabled ? 'none' : undefined}
ref={setRef}
style={[
styles.root,

View File

@@ -126,6 +126,7 @@ function TouchableOpacity(props: Props, forwardedRef): React.Node {
{...pressEventHandlers}
accessibilityDisabled={disabled}
focusable={!disabled && focusable !== false}
pointerEvents={disabled ? 'none' : undefined}
ref={setRef}
style={[
styles.root,