Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Fixes focus state on choice / select forms

Ian MacCallumac4c6eba6627
diff --git a/apps/web/ui/partners/design/edit-list.tsx b/apps/web/ui/partners/design/edit-list.tsx
index 3c5f5873bb..eac10f641c 100644
--- a/apps/web/ui/partners/design/edit-list.tsx
+++ b/apps/web/ui/partners/design/edit-list.tsx
@@ -22,7 +22,7 @@ const EditListContext = createContext<{
setExpandedValue: Dispatch<SetStateAction<string | null>>;
}>({
expandedValue: null,
- setExpandedValue: () => { },
+ setExpandedValue: () => {},
});
export function EditList({
@@ -75,11 +75,13 @@ export function EditListItem({
title,
onRemove,
error,
+ className,
}: {
value: string;
title: ReactNode;
- error?: boolean
+ error?: boolean;
onRemove?: () => void;
+ className?: string;
}) {
const controls = useDragControls();
@@ -89,7 +91,11 @@ export function EditListItem({
value={value}
dragListener={false}
dragControls={controls}
- className={cn("relative overflow-hidden rounded-md border border-neutral-200 bg-neutral-50", error && "border-red-500")}
+ className={cn(
+ "relative overflow-hidden rounded-md border border-neutral-200 bg-neutral-50",
+ className,
+ error && "border-red-500",
+ )}
initial={{ opacity: 0, height: 0 }}
animate={{ opacity: 1, height: "auto" }}
exit={{ opacity: 0, height: 0 }}
@@ -104,9 +110,7 @@ export function EditListItem({
<GripDotsVertical className="size-4 text-neutral-800" />
</div>
- <div className="px-6">
- {title}
- </div>
+ <div className="px-6">{title}</div>
{onRemove && (
<button
diff --git a/apps/web/ui/partners/groups/design/modals/multiple-choice-field-modal.tsx b/apps/web/ui/partners/groups/design/modals/multiple-choice-field-modal.tsx
index cbf8cfb2e6..5fe90a4536 100644
--- a/apps/web/ui/partners/groups/design/modals/multiple-choice-field-modal.tsx
+++ b/apps/web/ui/partners/groups/design/modals/multiple-choice-field-modal.tsx
@@ -221,20 +221,23 @@ function MultipleChoiceFieldModalInner({
}
>
{fields.map((field, index) => {
- const fieldErrors = errors.data?.options?.[index];
+ const error = errors.data?.options?.[index]?.value;
return (
<EditListItem
key={field.id}
value={field.id}
- error={!!fieldErrors?.value}
+ error={!!error?.message}
+ className={cn(
+ !error && "focus-within:border-neutral-500",
+ )}
title={
<input
id={`${id}-${field.id}-name`}
type="text"
placeholder="Option"
className={cn(
- "my-1 block w-full rounded-md border-transparent bg-transparent py-1 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500",
+ "my-1 block w-full rounded-md border-transparent bg-transparent py-1 text-sm text-neutral-900 placeholder-neutral-400 focus:border-transparent focus:outline-none focus:ring-0",
)}
{...register(`data.options.${index}.value`, {
required: "Value is required",
diff --git a/apps/web/ui/partners/groups/design/modals/select-field-modal.tsx b/apps/web/ui/partners/groups/design/modals/select-field-modal.tsx
index eada934d39..82d49d2ac8 100644
--- a/apps/web/ui/partners/groups/design/modals/select-field-modal.tsx
+++ b/apps/web/ui/partners/groups/design/modals/select-field-modal.tsx
@@ -193,20 +193,23 @@ function SelectFieldModalInner({
}
>
{fields.map((field, index) => {
- const fieldErrors = errors.data?.options?.[index];
+ const error = errors.data?.options?.[index]?.value;
return (
<EditListItem
key={field.id}
value={field.id}
- error={!!fieldErrors?.value}
+ error={!!error?.message}
+ className={cn(
+ !error && "focus-within:border-neutral-500",
+ )}
title={
<input
id={`${id}-${field.id}-name`}
type="text"
placeholder="Option"
className={cn(
- "my-1 block w-full rounded-md border-transparent bg-transparent py-1 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500",
+ "my-1 block w-full rounded-md border-transparent bg-transparent py-1 text-sm text-neutral-900 placeholder-neutral-400 focus:border-transparent focus:outline-none focus:ring-0",
)}
{...register(`data.options.${index}.value`, {
required: "Value is required",