@@ -41,6 +41,7 @@ import { Label } from "~/components/primitives/Label";
4141import { NavBar , PageAccessories , PageTitle } from "~/components/primitives/PageHeader" ;
4242import { Paragraph } from "~/components/primitives/Paragraph" ;
4343import * as Property from "~/components/primitives/PropertyTable" ;
44+ import { Select , SelectItem } from "~/components/primitives/Select" ;
4445import { SpinnerWhite } from "~/components/primitives/Spinner" ;
4546import { SimpleTooltip } from "~/components/primitives/Tooltip" ;
4647import { cn } from "~/utils/cn" ;
@@ -582,37 +583,33 @@ function RolePicker({
582583
583584 return (
584585 < div className = "flex flex-col items-end gap-1" >
585- < fetcher . Form method = "post" >
586- < input type = "hidden" name = "_formType" value = "set-role" />
587- < input type = "hidden" name = "userId" value = { memberUserId } />
588- < select
589- name = "roleId"
590- defaultValue = { currentRoleId ?? "" }
591- disabled = { ! canManageMembers || isSubmitting }
592- onChange = { ( e ) => {
593- // Auto-submit on change so users don't need a separate
594- // "Save" button. The fetcher posts to the current route's
595- // action.
596- ( e . currentTarget . form as HTMLFormElement ) . requestSubmit ( ) ;
597- } }
598- className = "rounded-sm border border-charcoal-700 bg-charcoal-800 px-2 py-1 text-sm text-text-bright disabled:cursor-not-allowed disabled:opacity-50"
599- >
600- { currentRoleId === null && (
601- < option value = "" disabled >
602- No role
603- </ option >
604- ) }
605- { roles . map ( ( role ) => {
586+ < Select < string , Role >
587+ defaultValue = { currentRoleId ?? "" }
588+ items = { roles }
589+ variant = "tertiary/small"
590+ disabled = { ! canManageMembers || isSubmitting }
591+ dropdownIcon
592+ text = { ( v ) => roles . find ( ( r ) => r . id === v ) ?. name ?? "No role" }
593+ setValue = { ( next ) => {
594+ if ( typeof next !== "string" || next === ( currentRoleId ?? "" ) ) return ;
595+ fetcher . submit (
596+ { _formType : "set-role" , userId : memberUserId , roleId : next } ,
597+ { method : "post" }
598+ ) ;
599+ } }
600+ >
601+ { ( items ) =>
602+ items . map ( ( role ) => {
606603 const isAssignable = assignable . has ( role . id ) ;
607604 return (
608- < option key = { role . id } value = { role . id } disabled = { ! isAssignable } >
605+ < SelectItem key = { role . id } value = { role . id } disabled = { ! isAssignable } >
609606 { role . name }
610607 { ! isAssignable ? " (upgrade)" : "" }
611- </ option >
608+ </ SelectItem >
612609 ) ;
613- } ) }
614- </ select >
615- </ fetcher . Form >
610+ } )
611+ }
612+ </ Select >
616613 { error ? (
617614 < span className = "text-xs text-error" role = "alert" >
618615 { error }
0 commit comments