fix: hidden settings menu affects settings layout (#7769)

This PR fixes #6746

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
ZiaCodes
2024-10-22 00:28:01 +05:00
committed by GitHub
parent 4407b1aaa2
commit 5e2df81211
7 changed files with 56 additions and 37 deletions

View File

@ -1,6 +1,6 @@
import { fireEvent, renderHook } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { MemoryRouter, useLocation } from 'react-router-dom';
import { fireEvent, renderHook } from '@testing-library/react';
import { RecoilRoot } from 'recoil';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
@ -23,7 +23,7 @@ const renderHookConfig = {
describe('useGoToHotkeys', () => {
it('should navigate on hotkey trigger', () => {
const { result } = renderHook(() => {
useGoToHotkeys('a', '/three');
useGoToHotkeys({ key: 'a', location: '/three' });
const setHotkeyScope = useSetHotkeyScope();

View File

@ -5,13 +5,24 @@ import { AppHotkeyScope } from '../types/AppHotkeyScope';
import { useSequenceHotkeys } from './useSequenceScopedHotkeys';
export const useGoToHotkeys = (key: Keys, location: string) => {
type GoToHotkeysProps = {
key: Keys;
location: string;
preNavigateFunction?: () => void;
};
export const useGoToHotkeys = ({
key,
location,
preNavigateFunction,
}: GoToHotkeysProps) => {
const navigate = useNavigate();
useSequenceHotkeys(
'g',
key,
() => {
preNavigateFunction?.();
navigate(location);
},
AppHotkeyScope.Goto,