Skip to content

Commit b9992e8

Browse files
committed
fix: tweaks showClaimPrompt to prevent it disappear during fetching
1 parent 25b8ea2 commit b9992e8

File tree

1 file changed

+53
-35
lines changed

1 file changed

+53
-35
lines changed

app/pages/search.vue

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,19 @@ const canPublishToScope = computed(() => {
354354
355355
// Show claim prompt when valid name, available, either not connected or connected and has permission
356356
const showClaimPrompt = computed(() => {
357-
return (
358-
isValidPackageName.value &&
359-
packageAvailability.value?.available === true &&
360-
packageAvailability.value.name === committedQuery.value.trim() &&
361-
(!isConnected.value || (isConnected.value && canPublishToScope.value)) &&
362-
status.value !== 'pending'
363-
)
357+
if (!isValidPackageName.value) return false
358+
if (isConnected.value && !canPublishToScope.value) return false
359+
360+
const avail = packageAvailability.value
361+
362+
// Confirmed: availability result matches current committed query
363+
if (avail?.available === true && avail.name === committedQuery.value.trim()) return true
364+
365+
// Pending: a new fetch is in flight — keep the claim visible if the last known
366+
// result was "available" so it doesn't flicker until new data arrives
367+
if (status.value === 'pending' && avail?.available === true) return true
368+
369+
return false
364370
})
365371
366372
const claimPackageModalRef = useTemplateRef('claimPackageModalRef')
@@ -711,22 +717,28 @@ onBeforeUnmount(() => {
711717
status === 'success'
712718
"
713719
>
714-
<div
715-
v-if="validatedSuggestions.length > 0 && displayResults.length > 0"
716-
class="mb-6 space-y-3"
720+
<Transition
721+
enter-active-class="motion-safe:animate-slide-up motion-safe:animate-fill-both"
722+
leave-active-class="motion-safe:transition-[opacity,transform] motion-safe:duration-200 motion-safe:ease-out"
723+
leave-to-class="opacity-0 motion-safe:-translate-y-1.5"
717724
>
718-
<SearchSuggestionCard
719-
v-for="(suggestion, idx) in validatedSuggestions"
720-
:key="`${suggestion.type}-${suggestion.name}`"
721-
:type="suggestion.type"
722-
:name="suggestion.name"
723-
:index="idx"
724-
:is-exact-match="
725-
(exactMatchType === 'org' && suggestion.type === 'org') ||
726-
(exactMatchType === 'user' && suggestion.type === 'user')
727-
"
728-
/>
729-
</div>
725+
<div
726+
v-if="validatedSuggestions.length > 0 && displayResults.length > 0"
727+
class="mb-6 space-y-3"
728+
>
729+
<SearchSuggestionCard
730+
v-for="(suggestion, idx) in validatedSuggestions"
731+
:key="`${suggestion.type}-${suggestion.name}`"
732+
:type="suggestion.type"
733+
:name="suggestion.name"
734+
:index="idx"
735+
:is-exact-match="
736+
(exactMatchType === 'org' && suggestion.type === 'org') ||
737+
(exactMatchType === 'user' && suggestion.type === 'user')
738+
"
739+
/>
740+
</div>
741+
</Transition>
730742

731743
<div
732744
v-if="showClaimPrompt && visibleResults && displayResults.length > 0"
@@ -823,19 +835,25 @@ onBeforeUnmount(() => {
823835
{{ $t('search.no_results', { query }) }}
824836
</p>
825837

826-
<div v-if="validatedSuggestions.length > 0" class="max-w-md mx-auto mb-6 space-y-3">
827-
<SearchSuggestionCard
828-
v-for="(suggestion, idx) in validatedSuggestions"
829-
:key="`${suggestion.type}-${suggestion.name}`"
830-
:type="suggestion.type"
831-
:name="suggestion.name"
832-
:index="idx"
833-
:is-exact-match="
834-
(exactMatchType === 'org' && suggestion.type === 'org') ||
835-
(exactMatchType === 'user' && suggestion.type === 'user')
836-
"
837-
/>
838-
</div>
838+
<Transition
839+
enter-active-class="motion-safe:animate-slide-up motion-safe:animate-fill-both"
840+
leave-active-class="motion-safe:transition-[opacity,transform] motion-safe:duration-200 motion-safe:ease-out"
841+
leave-to-class="opacity-0 motion-safe:-translate-y-1.5"
842+
>
843+
<div v-if="validatedSuggestions.length > 0" class="max-w-md mx-auto mb-6 space-y-3">
844+
<SearchSuggestionCard
845+
v-for="(suggestion, idx) in validatedSuggestions"
846+
:key="`${suggestion.type}-${suggestion.name}`"
847+
:type="suggestion.type"
848+
:name="suggestion.name"
849+
:index="idx"
850+
:is-exact-match="
851+
(exactMatchType === 'org' && suggestion.type === 'org') ||
852+
(exactMatchType === 'user' && suggestion.type === 'user')
853+
"
854+
/>
855+
</div>
856+
</Transition>
839857

840858
<div v-if="showClaimPrompt" class="max-w-md mx-auto text-center hidden sm:block">
841859
<div class="p-4 bg-bg-subtle border border-border rounded-lg">

0 commit comments

Comments
 (0)