Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions apps/webapp/app/components/primitives/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,17 @@ export const Button = forwardRef<HTMLButtonElement, ButtonPropsType>(
const innerRef = useRef<HTMLButtonElement>(null);
useImperativeHandle(ref, () => innerRef.current as HTMLButtonElement);

if (props.shortcut) {
useShortcutKeys({
shortcut: props.shortcut,
action: (e) => {
if (innerRef.current) {
innerRef.current.click();
e.preventDefault();
e.stopPropagation();
}
},
disabled,
});
}
useShortcutKeys({
shortcut: props.shortcut,
action: (e) => {
if (innerRef.current) {
innerRef.current.click();
e.preventDefault();
e.stopPropagation();
}
},
disabled: disabled || !props.shortcut,
});

return (
<button
Expand Down Expand Up @@ -345,16 +343,16 @@ export const LinkButton = ({
...props
}: LinkPropsType) => {
const innerRef = useRef<HTMLAnchorElement>(null);
if (props.shortcut) {
useShortcutKeys({
shortcut: props.shortcut,
action: () => {
if (innerRef.current) {
innerRef.current.click();
}
},
});
}

useShortcutKeys({
shortcut: props.shortcut,
action: () => {
if (innerRef.current) {
innerRef.current.click();
}
},
disabled: disabled || !props.shortcut,
});

if (disabled) {
return (
Expand Down
6 changes: 5 additions & 1 deletion apps/webapp/app/routes/admin._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,17 @@ export default function AdminDashboardRoute() {
<TableCell isSticky={true}>
<Form method="post" reloadDocument>
<input type="hidden" name="id" value={user.id} />

<Button
type="submit"
name="action"
value="impersonate"
className="mr-2"
variant="tertiary/small"
shortcut={
users.length === 1
? { modifiers: ["mod"], key: "enter", enabledOnInputElements: true }
: undefined
}
>
Impersonate
</Button>
Expand Down
5 changes: 5 additions & 0 deletions apps/webapp/app/routes/admin.orgs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ export default function AdminDashboardRoute() {
to={`/@/orgs/${org.slug}`}
className="mr-2"
variant="tertiary/small"
shortcut={
organizations.length === 1
? { modifiers: ["mod"], key: "enter", enabledOnInputElements: true }
: undefined
}
>
Impersonate
</LinkButton>
Expand Down
Loading