From f9e5a22cd96b931a2a3ac92dae3d0c9fedf35bf1 Mon Sep 17 00:00:00 2001 From: Kai Rollmann Date: Thu, 3 Sep 2026 10:54:07 +0200 Subject: [PATCH 1/2] refactor(frontend): buttons on react-aria Button --- frontend/src/js/button/BasicButton.tsx | 60 ++++++++++--------- .../list/DeleteProjectItemButton.tsx | 2 +- .../js/previous-queries/list/ProjectItem.tsx | 2 +- frontend/src/js/search-bar/SearchBar.tsx | 2 +- .../QueryClearButton.tsx | 2 +- frontend/src/js/ui-components/BaseInput.tsx | 3 +- frontend/src/js/ui-components/ImportModal.tsx | 4 +- .../InputTextarea/InputTextarea.tsx | 3 +- .../src/js/ui-components/TooManyValues.tsx | 1 - 9 files changed, 40 insertions(+), 39 deletions(-) diff --git a/frontend/src/js/button/BasicButton.tsx b/frontend/src/js/button/BasicButton.tsx index 2a3f3dec0b..5fc75c076d 100644 --- a/frontend/src/js/button/BasicButton.tsx +++ b/frontend/src/js/button/BasicButton.tsx @@ -1,9 +1,20 @@ -import type { ButtonHTMLAttributes, Ref } from "react"; -import { mergeProps, useFocusable, useObjectRef } from "react-aria"; +import type { CSSProperties, ReactNode, Ref } from "react"; +import { + Button as RacButton, + type ButtonProps as RacButtonProps, +} from "react-aria-components"; import { tv } from "tailwind-variants"; export interface BasicButtonProps - extends ButtonHTMLAttributes { + extends Omit< + RacButtonProps, + "className" | "style" | "children" | "isDisabled" + > { + className?: string; + style?: CSSProperties; + children?: ReactNode; + /** HTML name kept for now, mapped to react-aria's `isDisabled` */ + disabled?: boolean; bare?: boolean; tiny?: boolean; small?: boolean; @@ -33,6 +44,9 @@ const button = tv({ }, }); +// react-aria's Button is the trigger that TooltipTrigger, DialogTrigger and +// friends expect, so every button built on this one works inside them as is. +// `onClick` is react-aria's alias for `onPress` and receives a mouse event. const BasicButton = ({ ref, className, @@ -44,29 +58,21 @@ const BasicButton = ({ secondary, disabled, ...props -}: BasicButtonProps & { ref?: Ref }) => { - const domRef = useObjectRef(ref); - // A surrounding TooltipTrigger hands its hover/focus props to the - // nearest focusable element: this makes every button a tooltip trigger. - const { focusableProps } = useFocusable({ isDisabled: disabled }, domRef); - - return ( -