Skip to content

Commit

Permalink
Fixed button icon bug (twentyhq#5670)
Browse files Browse the repository at this point in the history
There was a bug with the isEmpty variable actually being a function from
lodash instead of the result of `isFieldEmpty()`.
  • Loading branch information
lucasbordeau committed May 29, 2024
1 parent 008813f commit bcb582f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ReactElement, useContext, useEffect, useRef } from 'react';
import isEmpty from 'lodash.isempty';
import { useRecoilValue } from 'recoil';
import { Key } from 'ts-key-enum';
import { IconArrowUpRight } from 'twenty-ui';

import { useClearField } from '@/object-record/record-field/hooks/useClearField';
import { useGetButtonIcon } from '@/object-record/record-field/hooks/useGetButtonIcon';
import { useIsFieldClearable } from '@/object-record/record-field/hooks/useIsFieldClearable';
import { useIsFieldEmpty } from '@/object-record/record-field/hooks/useIsFieldEmpty';
import { useIsFieldInputOnly } from '@/object-record/record-field/hooks/useIsFieldInputOnly';
import { useToggleEditOnlyInput } from '@/object-record/record-field/hooks/useToggleEditOnlyInput';
import { RecordTableCellContext } from '@/object-record/record-table/contexts/RecordTableCellContext';
Expand All @@ -16,6 +16,7 @@ import { useOpenRecordTableCellFromCell } from '@/object-record/record-table/rec
import { isSoftFocusUsingMouseState } from '@/object-record/record-table/states/isSoftFocusUsingMouseState';
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
import { isNonTextWritingKey } from '@/ui/utilities/hotkey/utils/isNonTextWritingKey';
import { isDefined } from '~/utils/isDefined';

import { TableHotkeyScope } from '../../types/TableHotkeyScope';

Expand All @@ -40,6 +41,8 @@ export const RecordTableCellSoftFocusMode = ({

const isFieldInputOnly = useIsFieldInputOnly();

const isEmpty = useIsFieldEmpty();

const isFieldClearable = useIsFieldClearable();

const toggleEditOnlyInput = useToggleEditOnlyInput();
Expand Down Expand Up @@ -119,7 +122,7 @@ export const RecordTableCellSoftFocusMode = ({
const buttonIcon = isFirstColumn ? IconArrowUpRight : customButtonIcon;

const showButton =
!!buttonIcon &&
isDefined(buttonIcon) &&
!editModeContentOnly &&
(!isFirstColumn || !isEmpty) &&
!isReadOnly;
Expand Down

0 comments on commit bcb582f

Please sign in to comment.