mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-23 20:54:50 +03:00
cmdk hotkeys work if input if focsed
This commit is contained in:
parent
70d61314a6
commit
0d21f17509
@ -61,7 +61,7 @@
|
||||
action.href.startsWith('http') || action.href.startsWith('mailto')
|
||||
? open(action.href)
|
||||
: goto(action.href);
|
||||
modal?.hide();
|
||||
modal?.close();
|
||||
} else if (Action.isGroup(action)) {
|
||||
selectedGroup.set(action);
|
||||
}
|
||||
@ -115,11 +115,9 @@
|
||||
if (command.hotkey) {
|
||||
unregisterCommandHotkeys.push(
|
||||
tinykeys(window, {
|
||||
[command.hotkey]: (event: KeyboardEvent) => {
|
||||
const target = event.target as HTMLElement;
|
||||
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') return;
|
||||
// only trigger if the modal is visible
|
||||
modal?.isOpen() && trigger(command.action);
|
||||
[command.hotkey]: () => {
|
||||
if (!modal?.isOpen()) return;
|
||||
trigger(command.action);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
@ -35,14 +35,15 @@ export type Group = {
|
||||
const goToProjectGroup = ({ projects, input }: { projects: Project[]; input: string }): Group => ({
|
||||
title: 'Go to project',
|
||||
commands: projects
|
||||
.map((project) => ({
|
||||
.filter(({ title }) => input.length === 0 || title.toLowerCase().includes(input.toLowerCase()))
|
||||
.map((project, i) => ({
|
||||
title: project.title,
|
||||
hotkey: `${i + 1}`,
|
||||
action: {
|
||||
href: `/projects/${project.id}/`
|
||||
},
|
||||
icon: IconProject
|
||||
}))
|
||||
.filter(({ title }) => input.length === 0 || title.toLowerCase().includes(input.toLowerCase()))
|
||||
});
|
||||
|
||||
const actionsGroup = ({ project, input }: { project: Project; input: string }): Group => ({
|
||||
@ -66,6 +67,7 @@ const actionsGroup = ({ project, input }: { project: Project; input: string }):
|
||||
},
|
||||
{
|
||||
title: 'Replay History',
|
||||
hotkey: 'Shift+R',
|
||||
action: {
|
||||
title: 'Replay working history',
|
||||
commands: [
|
||||
|
@ -12,7 +12,7 @@
|
||||
};
|
||||
export const isOpen = () => open;
|
||||
|
||||
const close = () => {
|
||||
export const close = () => {
|
||||
open = false;
|
||||
dialog.close();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user