fix: cmdk modal not closing when choosing an option (#1833)

This commit is contained in:
Dakshesh Jain 2023-08-11 17:16:37 +05:30 committed by GitHub
parent 6617049983
commit ad4cdcc512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -354,8 +354,8 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
<Command.Item <Command.Item
key={item.id} key={item.id}
onSelect={() => { onSelect={() => {
router.push(currentSection.path(item));
setIsPaletteOpen(false); setIsPaletteOpen(false);
router.push(currentSection.path(item));
}} }}
value={`${key}-${item?.name}`} value={`${key}-${item?.name}`}
className="focus:outline-none" className="focus:outline-none"
@ -379,6 +379,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
<Command.Group heading="Issue actions"> <Command.Group heading="Issue actions">
<Command.Item <Command.Item
onSelect={() => { onSelect={() => {
setIsPaletteOpen(false);
setPlaceholder("Change state..."); setPlaceholder("Change state...");
setSearchTerm(""); setSearchTerm("");
setPages([...pages, "change-issue-state"]); setPages([...pages, "change-issue-state"]);
@ -460,6 +461,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
<Command.Group heading="Issue"> <Command.Group heading="Issue">
<Command.Item <Command.Item
onSelect={() => { onSelect={() => {
setIsPaletteOpen(false);
const e = new KeyboardEvent("keydown", { const e = new KeyboardEvent("keydown", {
key: "c", key: "c",
}); });
@ -479,6 +481,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
<Command.Group heading="Project"> <Command.Group heading="Project">
<Command.Item <Command.Item
onSelect={() => { onSelect={() => {
setIsPaletteOpen(false);
const e = new KeyboardEvent("keydown", { const e = new KeyboardEvent("keydown", {
key: "p", key: "p",
}); });
@ -500,6 +503,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
<Command.Group heading="Cycle"> <Command.Group heading="Cycle">
<Command.Item <Command.Item
onSelect={() => { onSelect={() => {
setIsPaletteOpen(false);
const e = new KeyboardEvent("keydown", { const e = new KeyboardEvent("keydown", {
key: "q", key: "q",
}); });
@ -517,6 +521,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
<Command.Group heading="Module"> <Command.Group heading="Module">
<Command.Item <Command.Item
onSelect={() => { onSelect={() => {
setIsPaletteOpen(false);
const e = new KeyboardEvent("keydown", { const e = new KeyboardEvent("keydown", {
key: "m", key: "m",
}); });
@ -534,6 +539,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
<Command.Group heading="View"> <Command.Group heading="View">
<Command.Item <Command.Item
onSelect={() => { onSelect={() => {
setIsPaletteOpen(false);
const e = new KeyboardEvent("keydown", { const e = new KeyboardEvent("keydown", {
key: "v", key: "v",
}); });
@ -551,6 +557,7 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
<Command.Group heading="Page"> <Command.Group heading="Page">
<Command.Item <Command.Item
onSelect={() => { onSelect={() => {
setIsPaletteOpen(false);
const e = new KeyboardEvent("keydown", { const e = new KeyboardEvent("keydown", {
key: "d", key: "d",
}); });
@ -568,11 +575,12 @@ export const CommandK: React.FC<Props> = ({ deleteIssue, isPaletteOpen, setIsPal
{projectDetails && projectDetails.inbox_view && ( {projectDetails && projectDetails.inbox_view && (
<Command.Group heading="Inbox"> <Command.Group heading="Inbox">
<Command.Item <Command.Item
onSelect={() => onSelect={() => {
setIsPaletteOpen(false);
redirect( redirect(
`/${workspaceSlug}/projects/${projectId}/inbox/${inboxList?.[0]?.id}` `/${workspaceSlug}/projects/${projectId}/inbox/${inboxList?.[0]?.id}`
) );
} }}
className="focus:outline-none" className="focus:outline-none"
> >
<div className="flex items-center gap-2 text-custom-text-200"> <div className="flex items-center gap-2 text-custom-text-200">