Fix Bug 69075 - Accounts: Groups. Added support for "Enter" and "Backspace" hotkeys

This commit is contained in:
Nikita Gopienko 2024-07-09 16:07:31 +03:00
parent 536c456216
commit 6f649a24aa
4 changed files with 35 additions and 7 deletions

View File

@ -37,7 +37,8 @@ interface AccountsHotkeysProps {
activateHotkeys: (e: KeyboardEvent) => void;
selectAll: () => void;
deselectAll: () => void;
onClickBack: () => void;
openItem: () => void;
onClickBack: (fromHotkeys: boolean) => void;
}
const useAccountsHotkeys = ({
@ -48,6 +49,7 @@ const useAccountsHotkeys = ({
activateHotkeys,
selectAll,
deselectAll,
openItem,
onClickBack,
}: AccountsHotkeysProps) => {
const [isEnabled, setIsEnabled] = useState(true);
@ -83,6 +85,11 @@ const useAccountsHotkeys = ({
};
}, [onKeyDown]);
const onClickBackAction = () => {
deselectAll();
onClickBack(true);
};
useHotkeys(
"*",
(e) => {
@ -114,8 +121,11 @@ const useAccountsHotkeys = ({
// Deselect all accounts
useHotkeys("shift+n, ESC", deselectAll, hotkeysFilter);
//Back to parent folder
useHotkeys("Backspace", onClickBack, hotkeysFilter);
// Open item
useHotkeys("Enter", () => openItem(), hotkeysFilter);
// Back to parent folder
useHotkeys("Backspace", onClickBackAction, hotkeysFilter);
};
export default useAccountsHotkeys;

View File

@ -33,7 +33,6 @@ import Groups from "./Groups";
import InsideGroup from "./InsideGroup";
import { withTranslation } from "react-i18next";
import { Consumer } from "@docspace/shared/utils";
import withLoader from "SRC_DIR/HOCs/withLoader";
import { useAccountsHotkeys } from "../../Hooks";
@ -57,6 +56,7 @@ const SectionBodyContent = (props) => {
setHotkeyCaret,
selectAll,
deselectAll,
openItem,
onClickBack,
} = props;
@ -71,6 +71,7 @@ const SectionBodyContent = (props) => {
activateHotkeys,
selectAll,
deselectAll,
openItem,
onClickBack,
});
@ -165,7 +166,9 @@ export default inject(({ peopleStore, filesActionsStore }) => {
selectAll,
deselectAll,
openItem,
} = peopleStore.accountsHotkeysStore;
const { onClickBack } = filesActionsStore;
return {
accountsViewAs,
@ -187,7 +190,8 @@ export default inject(({ peopleStore, filesActionsStore }) => {
setHotkeyCaret,
selectAll,
deselectAll,
onClickBack: filesActionsStore.onClickBack,
openItem,
onClickBack,
};
})(
withTranslation(["People", "Common", "PeopleTranslations"])(

View File

@ -231,6 +231,19 @@ class AccountsHotkeysStore {
selectAll();
};
openItem = () => {
const someDialogIsOpen = checkDialogsOpen();
if (
this.isAccountsPage ||
this.accountsSelection.length !== 1 ||
someDialogIsOpen
)
return;
const item = this.accountsSelection[0];
this.peopleStore.groupsStore.openGroupAction(item.id, true, item.name);
};
activateHotkeys = (e: KeyboardEvent) => {
const infiniteLoaderComponent = document.getElementsByClassName(
"ReactVirtualized__List",

View File

@ -2443,8 +2443,8 @@ class FilesActionStore {
}
};
onClickBack = () => {
const { roomType, ...rest } = this.selectedFolderStore;
onClickBack = (fromHotkeys = true) => {
const { roomType } = this.selectedFolderStore;
const { setSelectedNode } = this.treeFoldersStore;
const { clearFiles, setBufferSelection } = this.filesStore;
const { clearInsideGroup, insideGroupBackUrl } =
@ -2510,6 +2510,7 @@ class FilesActionStore {
setSelectedNode(["accounts", "people", "filter"]);
if (fromHotkeys) return;
return window.DocSpace.navigate(`${path}?${params}`, { replace: true });
}
};