Skip to content
TypeScript

fix(mobile): prevent environment row taps from swallowing switches (#17677)

Rohith Kadaveru97986f7ec5c5
diff --git a/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx b/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx
index cfbd2545a61..5ea1f5c3dc5 100644
--- a/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx
+++ b/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx
@@ -191,30 +191,24 @@ function ConnectedCloudEnvironmentRow(props: {
setLastDescriptor(props.descriptor);
}
return (
- <Pressable
- accessibilityHint="Long press to remove from this device"
- accessibilityRole={props.onOpen ? "button" : undefined}
- accessibilityLabel={props.onOpen ? `Manage ${props.environment.environmentLabel}` : undefined}
- onPress={props.onOpen}
- onLongPress={props.onRemove}
- >
- <CloudEnvironmentRowShell
- opensDetails={props.onOpen !== undefined}
- connectionError={enabled || unsupported ? props.environment.connectionError : null}
- connectionErrorTraceId={enabled ? props.environment.connectionErrorTraceId : null}
- connectionState={enabled || unsupported ? props.environment.connectionState : "available"}
- errorExpanded={props.errorExpanded}
- label={props.environment.environmentLabel}
- machine={resolveEnvironmentMachineKind(
- serverConfig ?? (lastDescriptor === undefined ? null : { environment: lastDescriptor }),
- )}
- onValueChange={props.onSetEnabled}
- onToggleError={props.onToggleError}
- disabled={unsupported}
- {...(enabled || unsupported ? {} : { statusText: "Off" })}
- value={enabled}
- />
- </Pressable>
+ <CloudEnvironmentRowShell
+ opensDetails={props.onOpen !== undefined}
+ onOpen={props.onOpen}
+ onRemove={props.onRemove}
+ connectionError={enabled || unsupported ? props.environment.connectionError : null}
+ connectionErrorTraceId={enabled ? props.environment.connectionErrorTraceId : null}
+ connectionState={enabled || unsupported ? props.environment.connectionState : "available"}
+ errorExpanded={props.errorExpanded}
+ label={props.environment.environmentLabel}
+ machine={resolveEnvironmentMachineKind(
+ serverConfig ?? (lastDescriptor === undefined ? null : { environment: lastDescriptor }),
+ )}
+ onValueChange={props.onSetEnabled}
+ onToggleError={props.onToggleError}
+ disabled={unsupported}
+ {...(enabled || unsupported ? {} : { statusText: "Off" })}
+ value={enabled}
+ />
);
}
@@ -261,6 +255,8 @@ function CloudEnvironmentRow(props: {
function CloudEnvironmentRowShell(props: {
readonly showChevron?: boolean;
readonly opensDetails?: boolean;
+ readonly onOpen?: (() => void) | undefined;
+ readonly onRemove?: (() => void) | undefined;
readonly connectionError: string | null;
readonly connectionErrorTraceId: string | null;
readonly connectionState: EnvironmentConnectionPhase;
@@ -298,6 +294,8 @@ function CloudEnvironmentRowShell(props: {
const errorCanExpand = props.connectionError !== null && errorLineCount > 1;
const isErrorExpanded = errorCanExpand && props.errorExpanded;
const StatusContainer = errorCanExpand ? Pressable : View;
+ const ContentContainer = props.onOpen || props.onRemove ? Pressable : View;
+ const ChevronContainer = props.onOpen || props.onRemove ? Pressable : View;
const onMeasuredErrorTextLayout = useCallback(
(event: TextLayoutEvent) => {
if (!props.connectionError) {
@@ -315,7 +313,20 @@ function CloudEnvironmentRowShell(props: {
);
return (
<View collapsable={false} className="flex-row items-center gap-3 bg-grouped-card px-4 py-3.5">
- <View className="min-w-0 flex-1 gap-0.5">
+ <ContentContainer
+ className="min-w-0 flex-1 gap-0.5"
+ accessibilityHint={props.onRemove ? "Long press to remove from this device" : undefined}
+ accessibilityRole={props.onOpen ? "button" : undefined}
+ accessibilityLabel={
+ props.onOpen
+ ? `Manage ${props.label}`
+ : props.onRemove
+ ? `Remove ${props.label} from this device`
+ : undefined
+ }
+ onPress={props.onOpen}
+ onLongPress={props.onRemove}
+ >
<View className="min-w-0 flex-row items-center gap-2">
<ConnectionStatusDot state={props.connectionState} pulse={shouldPulse} size={7} />
<EnvironmentMachineSymbol
@@ -375,17 +386,37 @@ function CloudEnvironmentRowShell(props: {
/>
) : null}
</StatusContainer>
- </View>
+ </ContentContainer>
<ThemedSwitch
+ accessibilityLabel={`Enable ${props.label}`}
style={{ alignSelf: "center" }}
disabled={props.disabled}
onValueChange={props.onValueChange}
value={props.value}
/>
{props.opensDetails || props.showChevron ? (
- <View style={{ opacity: props.opensDetails ? 1 : 0.4 }}>
+ <ChevronContainer
+ accessibilityRole={props.onOpen ? "button" : undefined}
+ accessibilityLabel={
+ props.onOpen
+ ? `Manage ${props.label}`
+ : props.onRemove
+ ? `Remove ${props.label} from this device`
+ : undefined
+ }
+ accessibilityHint={props.onRemove ? "Long press to remove from this device" : undefined}
+ onPress={props.onOpen}
+ onLongPress={props.onRemove}
+ style={{
+ opacity: props.opensDetails ? 1 : 0.4,
+ minWidth: 44,
+ minHeight: 44,
+ alignItems: "center",
+ justifyContent: "center",
+ }}
+ >
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-subtle" />
- </View>
+ </ChevronContainer>
) : null}
</View>
);
diff --git a/apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx b/apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx
index f034dc46c46..610312f9350 100644
--- a/apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx
+++ b/apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx
@@ -78,15 +78,17 @@ export function ConnectionEnvironmentRow(props: {
return (
<Animated.View layout={LinearTransition.duration(250)} className="bg-grouped-card">
- <Pressable
- className="flex-row items-center gap-3 px-4 py-3.5 active:opacity-70"
- accessibilityRole="button"
- accessibilityLabel={
- props.opensDetails ? `Manage ${props.environment.environmentLabel}` : undefined
- }
- onPress={props.onToggle}
- >
- <View className="flex-1 gap-0.5">
+ <View className="flex-row items-center gap-3 px-4 py-3.5">
+ <Pressable
+ className="min-w-0 flex-1 gap-0.5 active:opacity-70"
+ accessibilityRole="button"
+ accessibilityLabel={
+ props.opensDetails
+ ? `Manage ${props.environment.environmentLabel}`
+ : `${props.expanded ? "Collapse" : "Expand"} details for ${props.environment.environmentLabel}`
+ }
+ onPress={props.onToggle}
+ >
<View className="flex-row items-center gap-1.5">
<ConnectionStatusDot
state={enabled || unsupported ? props.environment.connectionState : "available"}
@@ -129,24 +131,39 @@ export function ConnectionEnvironmentRow(props: {
) : null}
</Text>
) : null}
- </View>
+ </Pressable>
<ThemedSwitch
+ accessibilityLabel={`Enable ${props.environment.environmentLabel}`}
style={{ alignSelf: "center" }}
disabled={unsupported}
onValueChange={(next) => props.onSetEnabled(props.environment.environmentId, next)}
value={enabled}
/>
- <SymbolView
- name={props.opensDetails ? "chevron.right" : "chevron.down"}
- size={12}
- tintColorClassName="accent-icon-subtle"
- type="monochrome"
+ <Pressable
+ accessibilityRole="button"
+ accessibilityLabel={
+ props.opensDetails
+ ? `Manage ${props.environment.environmentLabel}`
+ : `${props.expanded ? "Collapse" : "Expand"} details for ${props.environment.environmentLabel}`
+ }
+ onPress={props.onToggle}
style={{
- transform: [{ rotate: props.expanded ? "180deg" : "0deg" }],
+ minWidth: 44,
+ minHeight: 44,
+ alignItems: "center",
+ justifyContent: "center",
}}
- />
- </Pressable>
+ >
+ <SymbolView
+ name={props.opensDetails ? "chevron.right" : "chevron.down"}
+ size={12}
+ tintColorClassName="accent-icon-subtle"
+ type="monochrome"
+ style={{ transform: [{ rotate: props.expanded ? "180deg" : "0deg" }] }}
+ />
+ </Pressable>
+ </View>
{props.expanded ? (
<Animated.View