Skip to content

Commit

Permalink
Flix flaky buttons (#13)
Browse files Browse the repository at this point in the history
Even though they're active, buttons are sometimes not actually
clickable.
Switching `Pressable` for `TouchableOpacity` seems to fix that
flakiness.
  • Loading branch information
dharmadeveloper108 authored May 8, 2024
1 parent 899acf3 commit 06d92f7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions example/app/porting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import Checkbox from 'expo-checkbox'
import { useCallback, useState } from 'react'
import {
Button,
Pressable,
ScrollView,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
View,
} from 'react-native'

Expand Down Expand Up @@ -171,7 +171,7 @@ export default function PortingEmbedScreen() {
)
}}
renderSecondaryButton={(name, onPress) => (
<Pressable onPress={onPress}>
<TouchableOpacity onPress={onPress}>
<Text
style={[
{
Expand All @@ -185,7 +185,7 @@ export default function PortingEmbedScreen() {
>
{titles[name]}
</Text>
</Pressable>
</TouchableOpacity>
)}
renderAlertBanner={(variant, message) => (
<View
Expand Down
9 changes: 5 additions & 4 deletions src/components/EmbedButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Pressable, PressableProps } from 'react-native'
import { TouchableOpacity, TouchableOpacityProps } from 'react-native'

import { useOptionsContext } from '../PortingEmbed/CustomOptionsProvider'
import { EmbedText } from './EmbedText'
Expand All @@ -9,7 +9,7 @@ type Props = {
disabled?: boolean
isSubmitting?: boolean
name?: string
} & PressableProps
} & TouchableOpacityProps

export function EmbedButton({
onPress,
Expand All @@ -23,7 +23,7 @@ export function EmbedButton({
return options?.renderPrimaryButton ? (
options.renderPrimaryButton(onPress, name, isSubmitting, disabled)
) : (
<Pressable
<TouchableOpacity
disabled={disabled}
style={[
{
Expand All @@ -32,6 +32,7 @@ export function EmbedButton({
padding: 12,
},
]}
onPress={onPress}
{...rest}
>
<EmbedText
Expand All @@ -46,6 +47,6 @@ export function EmbedButton({
>
{name}
</EmbedText>
</Pressable>
</TouchableOpacity>
)
}
8 changes: 4 additions & 4 deletions src/components/EmbedTextButton.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { ReactNode } from 'react'
import { Pressable, PressableProps } from 'react-native'
import { TouchableOpacity, TouchableOpacityProps } from 'react-native'

import { EmbedText } from './EmbedText'

type Props = {
children: ReactNode
} & PressableProps
} & TouchableOpacityProps

export function EmbedTextButton({ children, ...rest }: Props) {
return (
<Pressable {...rest}>
<TouchableOpacity {...rest}>
<EmbedText
style={[
{
Expand All @@ -22,6 +22,6 @@ export function EmbedTextButton({ children, ...rest }: Props) {
>
{children}
</EmbedText>
</Pressable>
</TouchableOpacity>
)
}
6 changes: 3 additions & 3 deletions src/components/FakeCheckBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { Pressable, StyleSheet, View } from 'react-native'
import { StyleSheet, TouchableOpacity, View } from 'react-native'

import { EmbedText } from './EmbedText'

Expand All @@ -17,10 +17,10 @@ export function FakeCheckBox({ onChecked, label }: CheckboxProps) {
}

return (
<Pressable onPress={toggleCheckbox} style={[styles.container]}>
<TouchableOpacity onPress={toggleCheckbox} style={[styles.container]}>
<View style={[styles.checkbox, checked ? styles.checked : null]} />
<EmbedText style={[{ fontSize: 16, marginLeft: 12 }]}>{label}</EmbedText>
</Pressable>
</TouchableOpacity>
)
}

Expand Down

0 comments on commit 06d92f7

Please sign in to comment.