From c70a9b82ab9c20556acac2a68eec0d5cf07e0749 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 8 Jun 2025 20:08:10 +0300 Subject: [PATCH] Refactor button event handlers to always use onPress instead of onClick --- app/components/FormWithConfirm.tsx | 1 - app/components/elements/Button.tsx | 3 ++- app/features/admin/routes/admin.tsx | 2 +- app/features/calendar/components/FiltersDialog.tsx | 2 +- app/features/calendar/routes/calendar.tsx | 2 +- app/features/sendouq-match/routes/q.match.$id.tsx | 2 +- .../tournament-bracket/components/Bracket/Swiss.tsx | 2 +- .../tournament-bracket/components/MatchActions.tsx | 4 ++-- .../components/OrganizerMatchMapListDialog.tsx | 2 +- .../tournament-bracket/components/TeamRosterInputs.tsx | 4 ++-- app/features/tournament/routes/to.$id.register.tsx | 8 ++++---- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/components/FormWithConfirm.tsx b/app/components/FormWithConfirm.tsx index 43369937b..bbd13ae43 100644 --- a/app/components/FormWithConfirm.tsx +++ b/app/components/FormWithConfirm.tsx @@ -90,7 +90,6 @@ export function FormWithConfirm({ {React.cloneElement(children, { // @ts-expect-error broke with @types/react upgrade. TODO: figure out narrower type than React.ReactNode - onClick: openDialog, // TODO: when SendouButton has overtaken Button, this line can be removed onPress: openDialog, type: "button", })} diff --git a/app/components/elements/Button.tsx b/app/components/elements/Button.tsx index c1a31afa7..dfe78020f 100644 --- a/app/components/elements/Button.tsx +++ b/app/components/elements/Button.tsx @@ -17,7 +17,8 @@ type ButtonVariant = | "minimal-success" | "minimal-destructive"; -export interface SendouButtonProps extends ReactAriaButtonProps { +export interface SendouButtonProps + extends Omit { variant?: ButtonVariant; size?: "miniscule" | "small" | "medium" | "big"; icon?: JSX.Element; diff --git a/app/features/admin/routes/admin.tsx b/app/features/admin/routes/admin.tsx index 8cc5a4035..01f2f4a2f 100644 --- a/app/features/admin/routes/admin.tsx +++ b/app/features/admin/routes/admin.tsx @@ -85,7 +85,7 @@ function FriendCodeLookUp() { } - onClick={() => setSearchParams({ friendCode })} + onPress={() => setSearchParams({ friendCode })} > Search diff --git a/app/features/calendar/components/FiltersDialog.tsx b/app/features/calendar/components/FiltersDialog.tsx index 8234e97ea..990f0010a 100644 --- a/app/features/calendar/components/FiltersDialog.tsx +++ b/app/features/calendar/components/FiltersDialog.tsx @@ -26,7 +26,7 @@ export function FiltersDialog({ filters }: { filters: CalendarFilters }) { } - onClick={() => setIsOpen(true)} + onPress={() => setIsOpen(true)} data-testid="filter-events-button" > {t("calendar:filter.button")} diff --git a/app/features/calendar/routes/calendar.tsx b/app/features/calendar/routes/calendar.tsx index 59ddb6c41..a5f3ed24b 100644 --- a/app/features/calendar/routes/calendar.tsx +++ b/app/features/calendar/routes/calendar.tsx @@ -318,7 +318,7 @@ function ClockHeader({ {hiddenEventsCount > 0 ? ( : } - onClick={onToggleHidden} + onPress={onToggleHidden} variant="minimal" className={styles.hiddenEventsButton} data-testid="hidden-events-button" diff --git a/app/features/sendouq-match/routes/q.match.$id.tsx b/app/features/sendouq-match/routes/q.match.$id.tsx index 335dec21b..844b1b88c 100644 --- a/app/features/sendouq-match/routes/q.match.$id.tsx +++ b/app/features/sendouq-match/routes/q.match.$id.tsx @@ -1292,7 +1292,7 @@ function MapListMap({ size="small" icon={} variant="minimal-destructive" - onClick={() => { + onPress={() => { const userId = user!.id; const groupMatchMapId = map.id; diff --git a/app/features/tournament-bracket/components/Bracket/Swiss.tsx b/app/features/tournament-bracket/components/Bracket/Swiss.tsx index 3839a3fdd..ef9af3686 100644 --- a/app/features/tournament-bracket/components/Bracket/Swiss.tsx +++ b/app/features/tournament-bracket/components/Bracket/Swiss.tsx @@ -104,7 +104,7 @@ export function SwissBracket({ {groups.map((g) => ( setSelectedGroupId(g.groupId)} + onPress={() => setSelectedGroupId(g.groupId)} className={clsx( "tournament-bracket__bracket-nav__link tournament-bracket__bracket-nav__link__big", { diff --git a/app/features/tournament-bracket/components/MatchActions.tsx b/app/features/tournament-bracket/components/MatchActions.tsx index c9ca883c7..a48ace6dd 100644 --- a/app/features/tournament-bracket/components/MatchActions.tsx +++ b/app/features/tournament-bracket/components/MatchActions.tsx @@ -391,7 +391,7 @@ function EditScoreForm({ setEditing(false)} + onPress={() => setEditing(false)} > Cancel @@ -406,7 +406,7 @@ function EditScoreForm({ variant="outlined" size="small" className="mx-auto" - onClick={() => setEditing(true)} + onPress={() => setEditing(true)} data-testid="revise-button" > Edit diff --git a/app/features/tournament-bracket/components/OrganizerMatchMapListDialog.tsx b/app/features/tournament-bracket/components/OrganizerMatchMapListDialog.tsx index 412262dbd..91c63f30e 100644 --- a/app/features/tournament-bracket/components/OrganizerMatchMapListDialog.tsx +++ b/app/features/tournament-bracket/components/OrganizerMatchMapListDialog.tsx @@ -106,7 +106,7 @@ export function OrganizerMatchMapListDialog({ variant="outlined" size="small" icon={} - onClick={() => setIsOpen(true)} + onPress={() => setIsOpen(true)} > Show maplist diff --git a/app/features/tournament-bracket/components/TeamRosterInputs.tsx b/app/features/tournament-bracket/components/TeamRosterInputs.tsx index 4e8d3e978..5a1135988 100644 --- a/app/features/tournament-bracket/components/TeamRosterInputs.tsx +++ b/app/features/tournament-bracket/components/TeamRosterInputs.tsx @@ -493,7 +493,7 @@ function RosterFormWithButtons({
setEditingRoster(true)} + onPress={() => setEditingRoster(true)} className="tournament-bracket__edit-roster-button" variant="minimal" data-testid="edit-active-roster-button" @@ -528,7 +528,7 @@ function RosterFormWithButtons({ { + onPress={() => { setEditingRoster(false); }} > diff --git a/app/features/tournament/routes/to.$id.register.tsx b/app/features/tournament/routes/to.$id.register.tsx index e3be70d61..90de9b92b 100644 --- a/app/features/tournament/routes/to.$id.register.tsx +++ b/app/features/tournament/routes/to.$id.register.tsx @@ -784,7 +784,7 @@ function TeamInfo({ setUploadedAvatar(null)} + onPress={() => setUploadedAvatar(null)} > {t("common:actions.edit")} @@ -841,7 +841,7 @@ function TeamInfo({ {t("common:actions.save")} @@ -1020,7 +1020,7 @@ function FillRoster({
copyToClipboard(inviteLink)} + onPress={() => copyToClipboard(inviteLink)} variant="outlined" > {t("common:actions.copyToClipboard")} @@ -1167,7 +1167,7 @@ function DeleteMember({ members }: { members: TournamentDataTeam["members"] }) { setExpanded(true)} + onPress={() => setExpanded(true)} > {t("tournament:pre.roster.delete.button")}