From 3ade85161983d35e852a75fb63f5a9ed21f9f3a3 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Fri, 21 Aug 2026 12:58:47 -0500 Subject: [PATCH 1/2] fix submit button loading state race --- app/ui/lib/Button.tsx | 25 +++++++++---------------- app/ui/styles/components/button.css | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/app/ui/lib/Button.tsx b/app/ui/lib/Button.tsx index a0ec80ef7..ccf0c8afd 100644 --- a/app/ui/lib/Button.tsx +++ b/app/ui/lib/Button.tsx @@ -6,7 +6,6 @@ * Copyright Oxide Computer Company */ import cn from 'classnames' -import * as m from 'motion/react-m' import { type MouseEventHandler, type ReactNode } from 'react' import { type BadgeColor } from '@oxide/design-system/ui' @@ -120,25 +119,19 @@ export const Button = ({ {...rest} > {loading && ( - + - + )} - {children} - + ) diff --git a/app/ui/styles/components/button.css b/app/ui/styles/components/button.css index 4e0ba40b6..fc8388e1a 100644 --- a/app/ui/styles/components/button.css +++ b/app/ui/styles/components/button.css @@ -8,6 +8,8 @@ .ox-button { @apply relative; + /* Approximates Motion's { type: 'spring', duration: 0.3, bounce: 0 }. */ + --button-loading-easing: cubic-bezier(0.35, 0.98, 0.35, 1); &:after { content: ''; @@ -72,3 +74,20 @@ .active-clicked:active:not(.visually-disabled) { @apply motion-safe:translate-y-px; } + +@keyframes button-spinner-in { + from { + opacity: 0; + transform: translateY(-25px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@media (prefers-reduced-motion: no-preference) { + .button-spinner-in { + animation: button-spinner-in 0.3s var(--button-loading-easing); + } +} From 277710bce65d2769737a8dc1313f9698a6d93988 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Fri, 21 Aug 2026 15:26:00 -0500 Subject: [PATCH 2/2] a bit of cleanup: add comments, move transition setup to CSS --- app/ui/lib/Button.tsx | 2 +- app/ui/styles/components/button.css | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/ui/lib/Button.tsx b/app/ui/lib/Button.tsx index ccf0c8afd..d7b3262d0 100644 --- a/app/ui/lib/Button.tsx +++ b/app/ui/lib/Button.tsx @@ -125,7 +125,7 @@ export const Button = ({ )}