Skip to content

Commit e0c8c09

Browse files
committed
LinkButton can accept conditionally shown shortcuts
1 parent c478836 commit e0c8c09

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,16 @@ export const LinkButton = ({
343343
...props
344344
}: LinkPropsType) => {
345345
const innerRef = useRef<HTMLAnchorElement>(null);
346-
if (props.shortcut) {
347-
useShortcutKeys({
348-
shortcut: props.shortcut,
349-
action: () => {
350-
if (innerRef.current) {
351-
innerRef.current.click();
352-
}
353-
},
354-
});
355-
}
346+
347+
useShortcutKeys({
348+
shortcut: props.shortcut,
349+
action: () => {
350+
if (innerRef.current) {
351+
innerRef.current.click();
352+
}
353+
},
354+
disabled: disabled || !props.shortcut,
355+
});
356356

357357
if (disabled) {
358358
return (

apps/webapp/app/routes/admin.orgs.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ export default function AdminDashboardRoute() {
117117
to={`/@/orgs/${org.slug}`}
118118
className="mr-2"
119119
variant="tertiary/small"
120+
shortcut={
121+
organizations.length === 1
122+
? { modifiers: ["mod"], key: "enter", enabledOnInputElements: true }
123+
: undefined
124+
}
120125
>
121126
Impersonate
122127
</LinkButton>

0 commit comments

Comments
 (0)