-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: The popover is not displaying properly when it is placed inside the form. #931
Comments
Hello There ! <template v-if="selectedValues.length > 0">
...
</template>
<template v-else>
...
</template> which makes the original DOM element not available during the second opening of An example of solution number 1: <template>
<Popover v-model:open="isPopoverOpen" :onOpenToggle="togglePopover">
<PopoverTrigger asChild>
<div>
<TagsInput v-if="selectedValues.length > 0"
:model-value="defaultValue"
class="flex w-full p-1 rounded-md border min-h-10 h-auto bg-inherit hover:bg-inherit"
>
<TagsInputItem
v-for="item in defaultValue.slice(0, maxCount)"
:key="item"
:value="item"
>
<Badge
:key="item"
:class="cn(multiSelectVariants({ variant }))"
:style="{ animationDuration: `${animation}s` }"
>
{{ getOption(item)?.label || item }}
<XCircle
class="ml-2 h-4 w-4 cursor-pointer"
@click.stop="toggleOption(item)"
/>
</Badge>
</TagsInputItem>
<!-- Place the controls always at the end -->
<div class="flex items-center justify-between ml-auto">
<XIcon
class="h-4 mx-2 cursor-pointer text-muted-foreground"
@click.stop="clearSelection"
/>
<Separator orientation="vertical" class="flex min-h-6 h-full" />
<ChevronDown
class="h-4 mx-2 cursor-pointer text-muted-foreground"
/>
</div>
</TagsInput>
<TagsInput v-else
variant="inverted"
:model-value="defaultValue"
class="flex w-full p-1 rounded-md border min-h-10 h-auto"
>
<TagsInputItem :value="{}">
<div className="flex items-center justify-between w-full mx-auto">
<span className="text-sm text-muted-foreground mx-3">
{{ placeholder }}
</span>
<ChevronDown
className="h-4 cursor-pointer text-muted-foreground mx-2"
/>
</div>
</TagsInputItem>
</TagsInput>
</div>
</PopoverTrigger>
<PopoverContent
class="w-auto p-0"
align="start"
side="bottom"
:sideOffset="4"
:closeOnContentClick="false"
>
<Command>
<CommandInput class="h-9" placeholder="Search framework..." />
<CommandEmpty>No framework found.</CommandEmpty>
<CommandList>
<CommandGroup>
<CommandItem
v-for="framework in options"
:key="framework.value"
:value="framework.value"
@select="
toggleOption(framework.value);
isPopoverOpen = false;
"
>
{{ framework.label }}
<CheckIcon
v-if="selectedValues.includes(framework.value)"
class="ml-auto h-4 w-4"
/>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
</template>
|
Reproduction
https://stackblitz.com/edit/tdkd3r-uvsouz
Describe the bug
The dropdown is implemented using a Popover component, which displays the options. However, when an option is selected, the Popover unexpectedly repositions itself to the top of the page, rather than staying below the input field.
Is there a way to force the Popover component to stay positioned below the input field, even when an option is selected?
##Multi Select##
System Info
The text was updated successfully, but these errors were encountered: