Fix/relation picker (#546)

* FIx pickers

* Fix

* Fix lint

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Lucas Bordeau
2023-07-09 03:43:41 +02:00
committed by GitHub
parent 9d25d003ca
commit 795bead1bb
6 changed files with 29 additions and 9 deletions

View File

@ -2,6 +2,8 @@ import { useCallback, useState } from 'react';
import { useRecoilState } from 'recoil';
import { v4 as uuidv4 } from 'uuid';
import { useHotkeysScopeOnBooleanState } from '@/hotkeys/hooks/useHotkeysScopeOnBooleanState';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { RecoilScope } from '@/recoil-scope/components/RecoilScope';
import { Column } from '@/ui/board/components/Board';
import { NewButton as UINewButton } from '@/ui/board/components/NewButton';
@ -71,6 +73,12 @@ export function NewButton({ pipelineId, columnId }: OwnProps) {
const onNewClick = useCallback(() => {
setIsCreatingCard(true);
}, [setIsCreatingCard]);
useHotkeysScopeOnBooleanState(
{ scope: InternalHotkeysScope.RelationPicker },
isCreatingCard,
);
return (
<>
{isCreatingCard && (

View File

@ -60,9 +60,10 @@ export function useEntitySelectScroll<
] as HTMLElement;
if (currentHoveredRef) {
console.log({ currentHoveredRef, containerRef });
scrollIntoView(currentHoveredRef, {
align: {
top: 0.275,
top: 0.15,
},
isScrollable: (target) => {
return target === containerRef.current;

View File

@ -80,6 +80,11 @@ export function FilterDropdownButton() {
}
}
useHotkeysScopeOnBooleanState(
{ scope: InternalHotkeysScope.RelationPicker },
tableFilterDefinitionUsedInDropdown?.type === 'entity',
);
return (
<DropdownButton
label="Filter"

View File

@ -1,8 +1,6 @@
import styled from '@emotion/styled';
import { useRecoilState } from 'recoil';
import { useHotkeysScopeOnBooleanState } from '@/hotkeys/hooks/useHotkeysScopeOnBooleanState';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { isDefined } from '@/utils/type-guards/isDefined';
import { Panel } from '../../Panel';
@ -21,11 +19,6 @@ export function RightDrawer() {
const [isRightDrawerOpen] = useRecoilState(isRightDrawerOpenState);
const [rightDrawerPage] = useRecoilState(rightDrawerPageState);
useHotkeysScopeOnBooleanState(
{ scope: InternalHotkeysScope.RightDrawer },
isRightDrawerOpen,
);
if (!isRightDrawerOpen || !isDefined(rightDrawerPage)) {
return <></>;
}

View File

@ -1,7 +1,12 @@
import { useRecoilValue } from 'recoil';
import { useCurrentHotkeysScope } from '@/hotkeys/hooks/useCurrentHotkeysScope';
import { useResetHotkeysScopeStack } from '@/hotkeys/hooks/useResetHotkeysScopeStack';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { isSoftFocusActiveState } from '../states/isSoftFocusActiveState';
import { isSomeInputInEditModeState } from '../states/isSomeInputInEditModeState';
import { useCloseCurrentCellInEditMode } from './useClearCellInEditMode';
import { useDisableSoftFocus } from './useDisableSoftFocus';
@ -12,7 +17,15 @@ export function useLeaveTableFocus() {
const disableSoftFocus = useDisableSoftFocus();
const closeCurrentCellInEditMode = useCloseCurrentCellInEditMode();
const isSoftFocusActive = useRecoilValue(isSoftFocusActiveState);
const isSomeInputInEditMode = useRecoilValue(isSomeInputInEditModeState);
return async function leaveTableFocus() {
// TODO: replace with scope ancestor ?
if (!isSoftFocusActive && !isSomeInputInEditMode) {
return;
}
if (currentHotkeysScope?.scope === InternalHotkeysScope.Table) {
return;
}

View File

@ -1,5 +1,5 @@
import { ArgsType, Field } from '@nestjs/graphql';
import { IsEmail, IsNotEmpty, IsString, MinLength } from 'class-validator';
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
@ArgsType()
export class ChallengeInput {