Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(ui): forwardRef Button so Radix popovers anchor to their trigger

Juan Denisdc9825ce2344
diff --git a/frontend/src/components/ui/button.jsx b/frontend/src/components/ui/button.jsx
index d798414d..d2b5ea44 100644
--- a/frontend/src/components/ui/button.jsx
+++ b/frontend/src/components/ui/button.jsx
@@ -32,16 +32,25 @@ function buttonVariants({ variant = 'default', size = 'default', className } = {
);
}
-function Button({ className, variant, size, asChild = false, ...props }) {
+// forwardRef is load-bearing, not ceremony: every Radix trigger used as
+// `<PopoverTrigger asChild><Button/></PopoverTrigger>` hands the button a ref
+// and uses that element as the popper's anchor. Without it React drops the ref
+// ("Function components cannot be given refs … Primitive.button.SlotClone"),
+// floating-ui never gets a reference element, and the panel is left parked at
+// its pre-position `translate(0, -200%)` — open, focusable and completely
+// off-screen. That is why Sort/Columns/Views/Filter looked like dead buttons.
+const Button = React.forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button';
return (
<Comp
+ ref={ref}
data-slot="button"
className={buttonVariants({ variant, size, className })}
{...props}
/>
);
-}
+});
+Button.displayName = 'Button';
export { Button, buttonVariants };