diff --git a/components/pages/Goals/MainPage/store.ts b/components/pages/Goals/MainPage/store.ts index 7e1f00f3..396a1fd9 100644 --- a/components/pages/Goals/MainPage/store.ts +++ b/components/pages/Goals/MainPage/store.ts @@ -5,6 +5,7 @@ import { BaseGoalsStore, GoalsModalsTypes } from "../stores/BaseGoalsStore"; import { GoalDataExtended } from "../types"; import { CreateGoalParams } from "../../../../stores/RootStore/Resources/GoalsStore"; import { KeyboardEvent } from 'react'; +import { AnimationsStore } from '../../../../stores/AnimationsStore'; export class GoalsStore extends BaseGoalsStore { keymap = { @@ -73,6 +74,8 @@ export class GoalsStore extends BaseGoalsStore { await this.root.resources.goals.add({ goal, ...otherParams }); await this.loadTaskList(); this.modals.close(); + + AnimationsStore.displayFireworks(); }, onClose: this.modals.close, }, diff --git a/components/pages/Goals/components/GoalList/GoalItem/view.tsx b/components/pages/Goals/components/GoalList/GoalItem/view.tsx index 1a50bbda..24a37184 100644 --- a/components/pages/Goals/components/GoalList/GoalItem/view.tsx +++ b/components/pages/Goals/components/GoalList/GoalItem/view.tsx @@ -68,6 +68,7 @@ export const GoalItemView = observer(function GoalItemView() { statusIconBottom={-0.5} statusIconRight={0.5} tabIndex={-1} + preventOnFocus onToggleOpen={store.handleEmojiPickerToggle} onNavigate={store.handleIconNavigate} onFocus={store.updateEditedGoal} diff --git a/components/pages/Goals/components/GoalList/SpaceItem/index.tsx b/components/pages/Goals/components/GoalList/SpaceItem/index.tsx index faa7f5d7..55cb9fed 100644 --- a/components/pages/Goals/components/GoalList/SpaceItem/index.tsx +++ b/components/pages/Goals/components/GoalList/SpaceItem/index.tsx @@ -45,7 +45,7 @@ export const SpaceItem = observer(function SpaceItem({ spaceId, goals }: Props) diff --git a/components/pages/Goals/components/GoalList/store.ts b/components/pages/Goals/components/GoalList/store.ts index ee2e19e0..177ab538 100644 --- a/components/pages/Goals/components/GoalList/store.ts +++ b/components/pages/Goals/components/GoalList/store.ts @@ -36,12 +36,12 @@ export class GoalListStore { }; hotkeyHandlers = { - ON_RESET_FOCUSED_GOAL: (event) => { - event.preventDefault(); + ON_RESET_FOCUSED_GOAL: () => { this.setFocusedGoalId(null); }, ON_NAVIGATE: (event: KeyboardEvent) => { event.preventDefault(); + if (!this.focusedGoalId) { this.setFirstGoalAsFocused(); } else if (!this.isFocusedGoalEditing && !this.isMenuOpenedForFocusedGoal) { @@ -89,65 +89,73 @@ export class GoalListStore { } } }, - START_GOAL_EDITING: (event) => { + START_GOAL_EDITING: (event: KeyboardEvent) => { if (!this.focusedGoalId) { return; } event.preventDefault(); + this.isFocusedGoalEditing = true; this.getGoalTitleElement(this.focusedGoalId).click(); }, ON_OPEN: (event: KeyboardEvent) => { - event.preventDefault(); if (this.isGoalFocusedAndNotEditing && (event.key !== 'Enter' || !this.isMenuOpenedForFocusedGoal)) { + event.preventDefault(); + this.isCommandWithAltPressed = true; this.callbacks?.onOpenGoal(this.focusedGoalId, this.listBySpaces); } }, - ON_DONE: (event) => { - event.preventDefault(); + ON_DONE: (event: KeyboardEvent) => { if (this.isGoalFocusedAndNotEditing) { + event.preventDefault(); + this.isMenuOpenedForFocusedGoal = false; this.isCommandWithAltPressed = true; this.doneGoal(this.focusedGoal); } }, - ON_WONT_DO: (event) => { - event.preventDefault(); + ON_WONT_DO: (event: KeyboardEvent) => { if (this.isGoalFocusedAndNotEditing) { + event.preventDefault(); + this.isMenuOpenedForFocusedGoal = false; this.isCommandWithAltPressed = true; this.callbacks?.onWontDo(this.focusedGoal); } }, - ON_CLONE: (event) => { - event.preventDefault(); + ON_CLONE: (event: KeyboardEvent) => { if (this.isGoalFocusedAndNotEditing) { + event.preventDefault(); + this.isMenuOpenedForFocusedGoal = false; this.isCommandWithAltPressed = true; this.cloneGoal(this.focusedGoal); } }, - ON_ARCHIVE: (event) => { - event.preventDefault(); + ON_ARCHIVE: (event: KeyboardEvent) => { if (this.isGoalFocusedAndNotEditing) { + event.preventDefault(); + this.isMenuOpenedForFocusedGoal = false; this.isCommandWithAltPressed = true; this.archiveGoal(this.focusedGoal); } }, - ON_DELETE: (event) => { - event.preventDefault(); + ON_DELETE: (event: KeyboardEvent) => { if (this.isGoalFocusedAndNotEditing) { + event.preventDefault(); + this.isMenuOpenedForFocusedGoal = false; this.isCommandWithAltPressed = true; this.handleDeleteGoal(this.focusedGoalId); } }, - QUICK_DELETE: async (event) => { - event.preventDefault(); + QUICK_DELETE: async (event: KeyboardEvent) => { if (this.isGoalFocusedAndNotEditing) { + event.preventDefault(); + this.isMenuOpenedForFocusedGoal = false; await this.deleteGoal(this.focusedGoalId); } diff --git a/components/pages/Goals/modals/GoalCreationModal/components/GoalCreationInformation.tsx b/components/pages/Goals/modals/GoalCreationModal/components/GoalCreationInformation.tsx index dd07b715..66461db5 100644 --- a/components/pages/Goals/modals/GoalCreationModal/components/GoalCreationInformation.tsx +++ b/components/pages/Goals/modals/GoalCreationModal/components/GoalCreationInformation.tsx @@ -74,7 +74,15 @@ export const GoalCreationInformation = observer( - + Task list { - if (!this.listWithCreator.list.openedTask) { - this.handleSimpleClose(); - } + this.handleCloseModal(); }, CHANGE_STATUS: () => { if (this.isUpdating && !this.selectStatus.isMenuOpen) { @@ -91,12 +88,24 @@ export class GoalCreationModalStore { this.handlePrevGoal(); }, CHANGE_STATUS_TO_TODO: () => { + if (this.isHotkeysForTasksAvailable) { + return; + } + this.handleUpdateStatus(GoalStatus.TODO); }, CHANGE_STATUS_TO_DONE: () => { + if (this.isHotkeysForTasksAvailable) { + return; + } + this.handleUpdateStatus(GoalStatus.DONE); }, CHANGE_STATUS_TO_WONT_DO: () => { + if (this.isHotkeysForTasksAvailable) { + return; + } + this.handleUpdateStatus(GoalStatus.WONT_DO); }, }; @@ -133,13 +142,13 @@ export class GoalCreationModalStore { isTaskExpanded = false; isDescriptionLoading: boolean = true; isGoalCreatingOrUpdating: boolean = false; - draggingTask: TaskData | null = null; goals: GoalData[] = []; currentGoalIndex: number = 0; error: string = ''; isCommentPopoverOpened: boolean = false; isInfoPopoverOpened: boolean = false; isSpaceCreateModalOpened: boolean = false; + isHotkeysForTasksAvailable: boolean = false; goal: GoalData = { id: uuidv4(), @@ -221,6 +230,17 @@ export class GoalCreationModalStore { return this.goal.status !== GoalStatus.TODO || this.goal.isArchived; } + handleCloseModal = () => { + if (this.listWithCreator.list.openedTask) { + this.listWithCreator.list.closeTask(); + } else if (this.isHotkeysForTasksAvailable) { + this.isHotkeysForTasksAvailable = false; + this.listWithCreator.list.removeFocus(); + } else { + this.handleSimpleClose(); + } + }; + handleCloseTask = () => { this.resizableConfig[0].size = 3; this.resizableConfig[2].size = 0; @@ -236,6 +256,14 @@ export class GoalCreationModalStore { onCloseTask: this.handleCloseTask, }; + enableHotkeysForTasks = () => { + this.isHotkeysForTasksAvailable = true; + }; + + disableHotkeysForTasks = () => { + this.isHotkeysForTasksAvailable = false; + }; + handleExpandTask = () => { this.isTaskExpanded = true; this.resizableConfig[0].size = 0; @@ -323,8 +351,12 @@ export class GoalCreationModalStore { onSubmit: () => { this.isOpen = false; submitCb?.(); + this.resetActiveElementFocus(); + }, + onClose: () => { + this.modals.close(); + this.resetActiveElementFocus(); }, - onClose: this.modals.close, }, }); } else { diff --git a/components/pages/Goals/modals/GoalCreationModal/view.tsx b/components/pages/Goals/modals/GoalCreationModal/view.tsx index 94093d91..6b25cd12 100644 --- a/components/pages/Goals/modals/GoalCreationModal/view.tsx +++ b/components/pages/Goals/modals/GoalCreationModal/view.tsx @@ -28,7 +28,7 @@ export const GoalCreationModalView = observer(function GoalCreationModal() { onClose={store.handleClose} onCloseComplete={store.handleCloseComplete} closeOnEsc={false} - onEsc={store.handleClose} + onEsc={store.handleCloseModal} blockScrollOnMount={false} size='full' isCentered diff --git a/components/pages/Goals/modals/GoalWontDoSubmitModal/store.ts b/components/pages/Goals/modals/GoalWontDoSubmitModal/store.ts index 76880b9b..4e3fa1d7 100644 --- a/components/pages/Goals/modals/GoalWontDoSubmitModal/store.ts +++ b/components/pages/Goals/modals/GoalWontDoSubmitModal/store.ts @@ -18,7 +18,7 @@ export class GoalWontDoSubmitModalStore { otherReason: string = ''; textareaRef: HTMLTextAreaElement = null; - navigation = new ListNavigation(); + navigation = new ListNavigation(undefined, true); validator = new Validator({ fieldsErrorsToCheck: () => ({ reason: [ErrorTypes.REQUIRED], diff --git a/components/pages/Goals/modals/GoalWontDoSubmitModal/view.tsx b/components/pages/Goals/modals/GoalWontDoSubmitModal/view.tsx index 5d570c1b..9022218c 100644 --- a/components/pages/Goals/modals/GoalWontDoSubmitModal/view.tsx +++ b/components/pages/Goals/modals/GoalWontDoSubmitModal/view.tsx @@ -41,7 +41,6 @@ export const GoalWontDoSubmitModalView = observer(function GoalWontDoSubmitModal