Skip to content

Commit c68eb2d

Browse files
authored
fix(webapp): concurrency limits modal cancels and resets limit on enter (#2804)
The Override concurrency limit modal has 2 type="submit" buttons. The first one in the DOM was firing when the "enter" key is hit which canceled and reset the limit instead which is a bad UX. ### The fix This fix adds a hidden button above in the DOM order which mirrors the Update Override button. Having a double submit button is rare in our modals so feels safe to add this to the specific modal that needs it. ### Alternative solution Switching the order of the buttons in the main FormButton component, then using `flex-row-reverse` to flip them back in CSS works, but it reverses the tab order. Adding a `tabIndex` to fix that issue didn't seem to work reliably.
1 parent 583d299 commit c68eb2d

File tree

2 files changed

+18
-0
lines changed
  • apps/webapp/app
    • components/primitives
    • routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.queues

2 files changed

+18
-0
lines changed

apps/webapp/app/components/primitives/FormButtons.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { cn } from "~/utils/cn";
33
export function FormButtons({
44
cancelButton,
55
confirmButton,
6+
defaultAction,
67
className,
78
}: {
89
cancelButton?: React.ReactNode;
910
confirmButton: React.ReactNode;
11+
defaultAction?: { name: string; value: string; disabled?: boolean };
1012
className?: string;
1113
}) {
1214
return (
@@ -16,6 +18,17 @@ export function FormButtons({
1618
className
1719
)}
1820
>
21+
{defaultAction && (
22+
<button
23+
type="submit"
24+
name={defaultAction.name}
25+
value={defaultAction.value}
26+
disabled={defaultAction.disabled}
27+
className="hidden"
28+
tabIndex={-1}
29+
aria-hidden="true"
30+
/>
31+
)}
1932
{cancelButton ? cancelButton : <div />} {confirmButton}
2033
</div>
2134
);

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.queues/route.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,11 @@ function QueueOverrideConcurrencyButton({
10031003
</div>
10041004

10051005
<FormButtons
1006+
defaultAction={{
1007+
name: "action",
1008+
value: "queue-override",
1009+
disabled: isLoading || !concurrencyLimit,
1010+
}}
10061011
confirmButton={
10071012
<Button
10081013
type="submit"

0 commit comments

Comments
 (0)