Skip to content

Commit db92d43

Browse files
committed
fix(sso): give the Enter shortcut the same guard as the Add domain button
The Enter handler called handleAdd unconditionally while the button was disabled during an in-flight add, so repeated presses could issue overlapping requests. Both now read one canAddDomain flag rather than duplicating the condition.
1 parent afd7e27 commit db92d43

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

apps/sim/ee/sso/components/verified-domains-section.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export function VerifiedDomainsSection({ organizationId }: VerifiedDomainsSectio
129129
}
130130

131131
const domains = data?.domains ?? []
132+
/** Single source of truth for both the Add chip and the Enter shortcut. */
133+
const canAddDomain = !addDomain.isPending && newDomain.trim().length > 0
132134

133135
return (
134136
<>
@@ -145,19 +147,14 @@ export function VerifiedDomainsSection({ organizationId }: VerifiedDomainsSectio
145147
onKeyDown={(event) => {
146148
// This section renders inside the SSO provider <form>, so a bare
147149
// Enter would submit that form instead of adding the domain.
148-
if (event.key === 'Enter') {
149-
event.preventDefault()
150-
void handleAdd()
151-
}
150+
if (event.key !== 'Enter') return
151+
event.preventDefault()
152+
if (canAddDomain) void handleAdd()
152153
}}
153154
placeholder='acme.com'
154155
className='min-w-0 flex-1'
155156
/>
156-
<Chip
157-
variant='primary'
158-
onClick={handleAdd}
159-
disabled={addDomain.isPending || !newDomain.trim()}
160-
>
157+
<Chip variant='primary' onClick={handleAdd} disabled={!canAddDomain}>
161158
{addDomain.isPending ? 'Adding...' : 'Add domain'}
162159
</Chip>
163160
</div>

0 commit comments

Comments
 (0)