Skip to content

Commit d6ce199

Browse files
fix(mobile): keep environment toggles independently tappable
1 parent 08e18b7 commit d6ce199

2 files changed

Lines changed: 63 additions & 48 deletions

File tree

‎apps/mobile/src/features/connection/CloudEnvironmentRows.tsx‎

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -219,30 +219,24 @@ function ConnectedCloudEnvironmentRow(props: {
219219
setLastDescriptor(props.descriptor);
220220
}
221221
return (
222-
<Pressable
223-
accessibilityHint="Long press to remove from this device"
224-
accessibilityRole={props.onOpen ? "button" : undefined}
225-
accessibilityLabel={props.onOpen ? `Manage ${props.environment.environmentLabel}` : undefined}
226-
onPress={props.onOpen}
227-
onLongPress={props.onRemove}
228-
>
229-
<CloudEnvironmentRowShell
230-
opensDetails={props.onOpen !== undefined}
231-
connectionError={enabled || unsupported ? props.environment.connectionError : null}
232-
connectionErrorTraceId={enabled ? props.environment.connectionErrorTraceId : null}
233-
connectionState={enabled || unsupported ? props.environment.connectionState : "available"}
234-
errorExpanded={props.errorExpanded}
235-
label={props.environment.environmentLabel}
236-
machine={resolveEnvironmentMachineKind(
237-
serverConfig ?? (lastDescriptor === undefined ? null : { environment: lastDescriptor }),
238-
)}
239-
onValueChange={props.onSetEnabled}
240-
onToggleError={props.onToggleError}
241-
disabled={unsupported}
242-
{...(enabled || unsupported ? {} : { statusText: "Off" })}
243-
value={enabled}
244-
/>
245-
</Pressable>
222+
<CloudEnvironmentRowShell
223+
opensDetails={props.onOpen !== undefined}
224+
onOpen={props.onOpen}
225+
onRemove={props.onRemove}
226+
connectionError={enabled || unsupported ? props.environment.connectionError : null}
227+
connectionErrorTraceId={enabled ? props.environment.connectionErrorTraceId : null}
228+
connectionState={enabled || unsupported ? props.environment.connectionState : "available"}
229+
errorExpanded={props.errorExpanded}
230+
label={props.environment.environmentLabel}
231+
machine={resolveEnvironmentMachineKind(
232+
serverConfig ?? (lastDescriptor === undefined ? null : { environment: lastDescriptor }),
233+
)}
234+
onValueChange={props.onSetEnabled}
235+
onToggleError={props.onToggleError}
236+
disabled={unsupported}
237+
{...(enabled || unsupported ? {} : { statusText: "Off" })}
238+
value={enabled}
239+
/>
246240
);
247241
}
248242

@@ -289,6 +283,8 @@ function CloudEnvironmentRow(props: {
289283
function CloudEnvironmentRowShell(props: {
290284
readonly showChevron?: boolean;
291285
readonly opensDetails?: boolean;
286+
readonly onOpen?: (() => void) | undefined;
287+
readonly onRemove?: (() => void) | undefined;
292288
readonly connectionError: string | null;
293289
readonly connectionErrorTraceId: string | null;
294290
readonly connectionState: EnvironmentConnectionPhase;
@@ -344,7 +340,14 @@ function CloudEnvironmentRowShell(props: {
344340
);
345341
return (
346342
<View collapsable={false} className="flex-row items-center gap-3 bg-grouped-card px-4 py-3.5">
347-
<View className="min-w-0 flex-1 gap-0.5">
343+
<Pressable
344+
className="min-w-0 flex-1 gap-0.5"
345+
accessibilityHint={props.onRemove ? "Long press to remove from this device" : undefined}
346+
accessibilityRole={props.onOpen ? "button" : undefined}
347+
accessibilityLabel={props.onOpen ? `Manage ${props.label}` : undefined}
348+
onPress={props.onOpen}
349+
onLongPress={props.onRemove}
350+
>
348351
<View className="min-w-0 flex-row items-center gap-2">
349352
<ConnectionStatusDot state={props.connectionState} pulse={shouldPulse} size={7} />
350353
<EnvironmentMachineSymbol
@@ -404,17 +407,25 @@ function CloudEnvironmentRowShell(props: {
404407
/>
405408
) : null}
406409
</StatusContainer>
407-
</View>
410+
</Pressable>
408411
<ThemedSwitch
412+
accessibilityLabel={`Enable ${props.label}`}
409413
style={{ alignSelf: "center" }}
410414
disabled={props.disabled}
411415
onValueChange={props.onValueChange}
412416
value={props.value}
413417
/>
414418
{props.opensDetails || props.showChevron ? (
415-
<View style={{ opacity: props.opensDetails ? 1 : 0.4 }}>
419+
<Pressable
420+
accessibilityRole={props.onOpen ? "button" : undefined}
421+
accessibilityLabel={props.onOpen ? `Manage ${props.label}` : undefined}
422+
onPress={props.onOpen}
423+
onLongPress={props.onRemove}
424+
hitSlop={8}
425+
style={{ opacity: props.opensDetails ? 1 : 0.4 }}
426+
>
416427
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-subtle" />
417-
</View>
428+
</Pressable>
418429
) : null}
419430
</View>
420431
);

‎apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx‎

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,13 @@ export function ConnectionEnvironmentRow(props: {
7878

7979
return (
8080
<Animated.View layout={LinearTransition.duration(250)} className="bg-grouped-card">
81-
<Pressable
82-
className="flex-row items-center gap-3 px-4 py-3.5 active:opacity-70"
83-
accessibilityRole="button"
84-
accessibilityLabel={
85-
props.opensDetails ? `Manage ${props.environment.environmentLabel}` : undefined
86-
}
87-
onPress={props.onToggle}
88-
>
89-
<View className="flex-1 gap-0.5">
81+
<View className="flex-row items-center gap-3 px-4 py-3.5">
82+
<Pressable
83+
className="min-w-0 flex-1 gap-0.5 active:opacity-70"
84+
accessibilityRole="button"
85+
accessibilityLabel={`Manage ${props.environment.environmentLabel}`}
86+
onPress={props.onToggle}
87+
>
9088
<View className="flex-row items-center gap-1.5">
9189
<ConnectionStatusDot
9290
state={enabled || unsupported ? props.environment.connectionState : "available"}
@@ -129,24 +127,30 @@ export function ConnectionEnvironmentRow(props: {
129127
) : null}
130128
</Text>
131129
) : null}
132-
</View>
130+
</Pressable>
133131

134132
<ThemedSwitch
133+
accessibilityLabel={`Enable ${props.environment.environmentLabel}`}
135134
style={{ alignSelf: "center" }}
136135
disabled={unsupported}
137136
onValueChange={(next) => props.onSetEnabled(props.environment.environmentId, next)}
138137
value={enabled}
139138
/>
140-
<SymbolView
141-
name={props.opensDetails ? "chevron.right" : "chevron.down"}
142-
size={12}
143-
tintColorClassName="accent-icon-subtle"
144-
type="monochrome"
145-
style={{
146-
transform: [{ rotate: props.expanded ? "180deg" : "0deg" }],
147-
}}
148-
/>
149-
</Pressable>
139+
<Pressable
140+
accessibilityRole="button"
141+
accessibilityLabel="Toggle environment details"
142+
onPress={props.onToggle}
143+
hitSlop={8}
144+
>
145+
<SymbolView
146+
name={props.opensDetails ? "chevron.right" : "chevron.down"}
147+
size={12}
148+
tintColorClassName="accent-icon-subtle"
149+
type="monochrome"
150+
style={{ transform: [{ rotate: props.expanded ? "180deg" : "0deg" }] }}
151+
/>
152+
</Pressable>
153+
</View>
150154

151155
{props.expanded ? (
152156
<Animated.View

0 commit comments

Comments
 (0)