UI: Update host end user form UX fixes (#36092)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #36056 

- Fix submitting form with keyboard enter
- Fix opening modal with keyboard enter

- [x] Manual QA
This commit is contained in:
jacobshandling 2025-11-20 14:53:00 -08:00 committed by GitHub
parent 8c3dc2aa2f
commit fa38994494
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 6 deletions

View file

@ -1232,7 +1232,14 @@ const HostDetailsPage = ({
isGlobalAdmin ||
isGlobalMaintainer
}
onClickUpdateUser={() => setShowUpdateEndUserModal(true)}
onClickUpdateUser={(
e:
| React.MouseEvent<HTMLButtonElement>
| React.KeyboardEvent<HTMLButtonElement>
) => {
e.preventDefault();
setShowUpdateEndUserModal(true);
}}
/>
{showActivityCard && (
<ActivityCard

View file

@ -31,7 +31,11 @@ interface IUserProps {
disableFullNameTooltip?: boolean;
disableGroupsTooltip?: boolean;
className?: string;
onClickUpdateUser?: () => void;
onClickUpdateUser?: (
e:
| React.MouseEvent<HTMLButtonElement>
| React.KeyboardEvent<HTMLButtonElement>
) => void;
}
const User = ({
@ -40,7 +44,7 @@ const User = ({
disableFullNameTooltip = false,
disableGroupsTooltip = false,
className,
onClickUpdateUser = noop,
onClickUpdateUser,
}: IUserProps) => {
const classNames = classnames(baseClass, className);

View file

@ -33,7 +33,8 @@ const UpdateEndUserModal = ({
const isEditing = !!userNameDisplayValue;
const [idpUsername, setIdpUsername] = useState(userNameDisplayValue || "");
const onSave = () => {
const onSave = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
onUpdate(idpUsername);
};
@ -43,7 +44,7 @@ const UpdateEndUserModal = ({
}
return (
<>
<form>
<form onSubmit={onSave}>
<InputField
label="Username (IdP)"
name="username_idp"
@ -57,7 +58,7 @@ const UpdateEndUserModal = ({
<Button
isLoading={isUpdating}
disabled={isUpdating || (!isEditing && idpUsername === "")}
onClick={onSave}
type="submit"
>
Save
</Button>