Fix flashing next button

This commit is contained in:
Eric Bailey
2025-08-07 16:18:21 -05:00
parent e648c3bff0
commit 95a625819c
2 changed files with 8 additions and 2 deletions
+7 -2
View File
@@ -42,6 +42,7 @@ export function StepHandle() {
const validCheck = validateServiceHandle(draftValue, state.userDomain) const validCheck = validateServiceHandle(draftValue, state.userDomain)
const { const {
debouncedUsername: debouncedDraftValue,
enabled: queryEnabled, enabled: queryEnabled,
query: {data: isHandleAvailable, isPending}, query: {data: isHandleAvailable, isPending},
} = useHandleAvailabilityQuery({ } = useHandleAvailabilityQuery({
@@ -124,11 +125,15 @@ export function StepHandle() {
) )
} }
const hasDebounceSettled = draftValue === debouncedDraftValue
const isHandleTaken = const isHandleTaken =
!isPending && !isPending &&
queryEnabled && queryEnabled &&
isHandleAvailable && isHandleAvailable &&
!isHandleAvailable.available !isHandleAvailable.available
const isNotReady = isPending || !hasDebounceSettled
const isNextDisabled =
!validCheck.overall || !!state.error || isNotReady ? true : isHandleTaken
const textFieldInvalid = const textFieldInvalid =
isHandleTaken || isHandleTaken ||
@@ -188,7 +193,7 @@ export function StepHandle() {
</Requirement> </Requirement>
{isHandleAvailable.suggestions && {isHandleAvailable.suggestions &&
isHandleAvailable.suggestions.length > 0 && isHandleAvailable.suggestions.length > 0 &&
gate('handle_suggestions') && ( (gate('handle_suggestions') || __DEV__) && (
<HandleSuggestions <HandleSuggestions
suggestions={isHandleAvailable.suggestions} suggestions={isHandleAvailable.suggestions}
onSelect={suggestion => { onSelect={suggestion => {
@@ -242,7 +247,7 @@ export function StepHandle() {
<Animated.View layout={native(LinearTransition)}> <Animated.View layout={native(LinearTransition)}>
<BackNextButtons <BackNextButtons
isLoading={isNextLoading} isLoading={isNextLoading}
isNextDisabled={!validCheck.overall || !!state.error || isHandleTaken} isNextDisabled={isNextDisabled}
onBackPress={onBackPress} onBackPress={onBackPress}
onNextPress={onNextPress} onNextPress={onNextPress}
/> />
+1
View File
@@ -39,6 +39,7 @@ export function useHandleAvailabilityQuery(
const debouncedHandle = useDebouncedValue(name, debounceDelayMs) const debouncedHandle = useDebouncedValue(name, debounceDelayMs)
return { return {
debouncedUsername: debouncedHandle,
enabled: enabled && name === debouncedHandle, enabled: enabled && name === debouncedHandle,
query: useQuery({ query: useQuery({
enabled: enabled && name === debouncedHandle, enabled: enabled && name === debouncedHandle,