A full-featured CRM built with React, shadcn/ui, and Supabase.
Fix tooltip delay, nested portals and select spacing
erwanMarmelabbdb622fc8c6f
diff --git a/src/components/admin/columns-button.tsx b/src/components/admin/columns-button.tsxindex 9dd5f29e..cef50d59 100644--- a/src/components/admin/columns-button.tsx+++ b/src/components/admin/columns-button.tsx@@ -163,11 +163,7 @@ export const ColumnsSelector = ({ children }: ColumnsSelectorProps) => {const observer = new MutationObserver(resolveContainer);- // The popover renders its content in a portal appended to <body>, so- // watching body's direct children is enough to catch it opening and- // closing. Watching the whole subtree instead would run this on every DOM- // mutation of the list for as long as the view is mounted.- observer.observe(document.body, { childList: true });+ observer.observe(document.body, { childList: true, subtree: true });return () => {observer.disconnect();diff --git a/src/components/admin/select-input.tsx b/src/components/admin/select-input.tsxindex ba166d93..c1c1cecb 100644--- a/src/components/admin/select-input.tsx+++ b/src/components/admin/select-input.tsx@@ -271,14 +271,14 @@ export const SelectInput = (props: SelectInputProps) => {onValueChange={handleChangeWithCreateSupport}><SelectTrigger- className={cn(- "w-full transition-all hover:bg-accent",- isClearable && "pr-11",- )}+ className={cn("w-full transition-all hover:bg-accent")}disabled={field.disabled}aria-labelledby={labelId}>- <SelectValue placeholder={renderEmptyItemOption()}>+ <SelectValue+ placeholder={renderEmptyItemOption()}+ className={cn(isClearable && "pr-6")}+ >{(value: string | null) => {if (!value || value === emptyValue) {return renderEmptyItemOption();diff --git a/src/components/ui/tooltip.test.tsx b/src/components/ui/tooltip.test.tsxnew file mode 100644index 00000000..c7df072e--- /dev/null+++ b/src/components/ui/tooltip.test.tsx@@ -0,0 +1,26 @@+import { render } from "vitest-browser-react"++import {+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from "@/components/ui/tooltip"++it("opens without waiting when no provider wraps it", async () => {+ const screen = await render(+ <Tooltip>+ <TooltipTrigger render={<button type="button" />}>+ Hover me+ </TooltipTrigger>+ <TooltipContent>Helpful</TooltipContent>+ </Tooltip>+ )++ await screen.getByRole("button", { name: "Hover me" }).hover()++ // Base UI falls back to a 600ms open delay when nothing provides one, so this+ // budget is what tells an instant tooltip from the default.+ await expect+ .element(screen.getByText("Helpful"), { timeout: 400 })+ .toBeVisible()+})diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsxindex 56da4b2c..e417c9a3 100644--- a/src/components/ui/tooltip.tsx+++ b/src/components/ui/tooltip.tsx@@ -17,7 +17,11 @@ function TooltipProvider({}function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {- return <TooltipPrimitive.Root data-slot="tooltip" {...props} />+ return (+ <TooltipProvider>+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />+ </TooltipProvider>+ )}function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {