Skip to content

Commit 06341e0

Browse files
committed
#248 open only one menu on keyboard shortcut
1 parent 74a5a5f commit 06341e0

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

data-browser/src/components/Dropdown/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ interface DropdownMenuProps {
2727
/** The list of menu items */
2828
items: Item[];
2929
trigger: DropdownTriggerRenderFunction;
30+
/** Enables the keyboard shortcut */
31+
isMainMenu?: boolean;
3032
}
3133

3234
/** Gets the index of an array and loops around when at the beginning or end */
@@ -89,6 +91,7 @@ function normalizeItems(items: Item[]) {
8991
export function DropdownMenu({
9092
items,
9193
trigger,
94+
isMainMenu,
9295
}: DropdownMenuProps): JSX.Element {
9396
const menuId = useId();
9497
const dropdownRef = useRef<HTMLDivElement>(null);
@@ -168,7 +171,7 @@ export function DropdownMenu({
168171
handleToggle();
169172
setUseKeys(true);
170173
},
171-
{},
174+
{ enabled: !!isMainMenu },
172175
[isActive],
173176
);
174177
// Click / open the item

data-browser/src/components/Navigation.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ function NavBar() {
129129

130130
{showButtons && subject && (
131131
<ResourceContextMenu
132+
isMainMenu
132133
subject={subject}
133134
trigger={MenuBarDropdownTrigger}
134135
/>

data-browser/src/components/ResourceContextMenu/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export interface ResourceContextMenuProps {
3232
hide?: string[];
3333
trigger?: DropdownTriggerRenderFunction;
3434
simple?: boolean;
35+
/** If it's the primary menu in the navbar. Used for triggering keyboard shortcut */
36+
isMainMenu?: boolean;
3537
}
3638

3739
/** Dropdown menu that opens a bunch of actions for some resource */
@@ -40,6 +42,7 @@ function ResourceContextMenu({
4042
hide,
4143
trigger,
4244
simple,
45+
isMainMenu,
4346
}: ResourceContextMenuProps) {
4447
const store = useStore();
4548
const navigate = useNavigate();
@@ -150,7 +153,13 @@ function ResourceContextMenu({
150153

151154
const triggerComp = trigger ?? buildDefaultTrigger(<FaEllipsisV />);
152155

153-
return <DropdownMenu items={filteredItems} trigger={triggerComp} />;
156+
return (
157+
<DropdownMenu
158+
items={filteredItems}
159+
trigger={triggerComp}
160+
isMainMenu={isMainMenu}
161+
/>
162+
);
154163
}
155164

156165
export default ResourceContextMenu;

0 commit comments

Comments
 (0)