Skip to content

The open alternative to Salesforce, designed for AI.

Revert "Refacto/abstract inplace input" (#535)

Charles Bochet611cda1f41ae
diff --git a/front/src/modules/companies/components/CompanyAccountOwnerPicker.tsx b/front/src/modules/companies/components/CompanyAccountOwnerPicker.tsx
index e844934c7b4..cae334dedff 100644
--- a/front/src/modules/companies/components/CompanyAccountOwnerPicker.tsx
+++ b/front/src/modules/companies/components/CompanyAccountOwnerPicker.tsx
@@ -4,7 +4,7 @@ import { useFilteredSearchEntityQuery } from '@/relation-picker/hooks/useFiltere
import { relationPickerSearchFilterScopedState } from '@/relation-picker/states/relationPickerSearchFilterScopedState';
import { EntityForSelect } from '@/relation-picker/types/EntityForSelect';
import { Entity } from '@/relation-picker/types/EntityTypeForSelect';
-import { useInplaceInput } from '@/ui/components/inplace-input/hooks/useCloseInplaceInput';
+import { useEditableCell } from '@/ui/components/editable-cell/hooks/useCloseEditableCell';
import {
Company,
User,
@@ -28,7 +28,7 @@ export function CompanyAccountOwnerPicker({ company }: OwnProps) {
);
const [updateCompany] = useUpdateCompanyMutation();
- const { closeInplaceInput } = useInplaceInput();
+ const { closeEditableCell } = useEditableCell();
const companies = useFilteredSearchEntityQuery({
queryHook: useSearchUserQuery,
@@ -52,7 +52,7 @@ export function CompanyAccountOwnerPicker({ company }: OwnProps) {
},
});
- closeInplaceInput();
+ closeEditableCell();
}
return (
diff --git a/front/src/modules/people/components/PeopleCompanyCell.tsx b/front/src/modules/people/components/PeopleCompanyCell.tsx
index 7a53f13e290..6b34efba714 100644
--- a/front/src/modules/people/components/PeopleCompanyCell.tsx
+++ b/front/src/modules/people/components/PeopleCompanyCell.tsx
@@ -1,7 +1,7 @@
import CompanyChip from '@/companies/components/CompanyChip';
import { useRecoilScopedState } from '@/recoil-scope/hooks/useRecoilScopedState';
import { EditableCell } from '@/ui/components/editable-cell/EditableCell';
-import { isCreateModeScopedState } from '@/ui/components/inplace-input/states/isCreateModeScopedState';
+import { isCreateModeScopedState } from '@/ui/components/editable-cell/states/isCreateModeScopedState';
import { getLogoUrlFromDomainName } from '@/utils/utils';
import { Company, Person } from '~/generated/graphql';
diff --git a/front/src/modules/people/components/PeopleCompanyCreateCell.tsx b/front/src/modules/people/components/PeopleCompanyCreateCell.tsx
index b0c2ac6175c..c66863b0dca 100644
--- a/front/src/modules/people/components/PeopleCompanyCreateCell.tsx
+++ b/front/src/modules/people/components/PeopleCompanyCreateCell.tsx
@@ -4,7 +4,7 @@ import { v4 } from 'uuid';
import { useRecoilScopedState } from '@/recoil-scope/hooks/useRecoilScopedState';
import { relationPickerSearchFilterScopedState } from '@/relation-picker/states/relationPickerSearchFilterScopedState';
-import { isCreateModeScopedState } from '@/ui/components/inplace-input/states/isCreateModeScopedState';
+import { isCreateModeScopedState } from '@/ui/components/editable-cell/states/isCreateModeScopedState';
import { DoubleTextInput } from '@/ui/components/inputs/DoubleTextInput';
import { useListenClickOutsideArrayOfRef } from '@/ui/hooks/useListenClickOutsideArrayOfRef';
import { logError } from '@/utils/logs/logError';
diff --git a/front/src/modules/people/components/PeopleCompanyPicker.tsx b/front/src/modules/people/components/PeopleCompanyPicker.tsx
index 04774db2873..8d659702f33 100644
--- a/front/src/modules/people/components/PeopleCompanyPicker.tsx
+++ b/front/src/modules/people/components/PeopleCompanyPicker.tsx
@@ -2,8 +2,8 @@ import { useRecoilScopedState } from '@/recoil-scope/hooks/useRecoilScopedState'
import { SingleEntitySelect } from '@/relation-picker/components/SingleEntitySelect';
import { useFilteredSearchEntityQuery } from '@/relation-picker/hooks/useFilteredSearchEntityQuery';
import { relationPickerSearchFilterScopedState } from '@/relation-picker/states/relationPickerSearchFilterScopedState';
-import { useInplaceInput } from '@/ui/components/inplace-input/hooks/useCloseInplaceInput';
-import { isCreateModeScopedState } from '@/ui/components/inplace-input/states/isCreateModeScopedState';
+import { useEditableCell } from '@/ui/components/editable-cell/hooks/useCloseEditableCell';
+import { isCreateModeScopedState } from '@/ui/components/editable-cell/states/isCreateModeScopedState';
import { getLogoUrlFromDomainName } from '@/utils/utils';
import {
CommentableType,
@@ -25,7 +25,7 @@ export function PeopleCompanyPicker({ people }: OwnProps) {
);
const [updatePeople] = useUpdatePeopleMutation();
- const { closeInplaceInput } = useInplaceInput();
+ const { closeEditableCell } = useEditableCell();
const companies = useFilteredSearchEntityQuery({
queryHook: useSearchCompanyQuery,
@@ -50,7 +50,7 @@ export function PeopleCompanyPicker({ people }: OwnProps) {
},
});
- closeInplaceInput();
+ closeEditableCell();
}
function handleCreate() {
diff --git a/front/src/modules/pipeline-progress/components/CompanyBoardCard.tsx b/front/src/modules/pipeline-progress/components/CompanyBoardCard.tsx
index 06c2f4944b7..903a9e5796a 100644
--- a/front/src/modules/pipeline-progress/components/CompanyBoardCard.tsx
+++ b/front/src/modules/pipeline-progress/components/CompanyBoardCard.tsx
@@ -4,7 +4,7 @@ import { IconCurrencyDollar } from '@tabler/icons-react';
import { RecoilScope } from '@/recoil-scope/components/RecoilScope';
import { EditableDate } from '@/ui/components/editable-cell/types/EditableDate';
-import { InplaceTextInput } from '@/ui/components/inplace-input/types/InplaceTextInput';
+import { EditableText } from '@/ui/components/editable-cell/types/EditableText';
import { CellContext } from '@/ui/tables/states/CellContext';
import { RowContext } from '@/ui/tables/states/RowContext';
@@ -113,7 +113,7 @@ export function CompanyBoardCard({
<span>
<IconCurrencyDollar size={theme.icon.size.md} />
<HackScope>
- <InplaceTextInput
+ <EditableText
content={pipelineProgress.amount?.toString() || ''}
placeholder="Opportunity amount"
changeHandler={(value) =>
diff --git a/front/src/modules/ui/components/editable-cell/EditableCell.tsx b/front/src/modules/ui/components/editable-cell/EditableCell.tsx
index dc21dcd627c..15152a5012a 100644
--- a/front/src/modules/ui/components/editable-cell/EditableCell.tsx
+++ b/front/src/modules/ui/components/editable-cell/EditableCell.tsx
@@ -1,9 +1,26 @@
import { ReactElement } from 'react';
+import styled from '@emotion/styled';
-import { InplaceInput } from '../inplace-input/InplaceInput';
+import { useRecoilScopedState } from '@/recoil-scope/hooks/useRecoilScopedState';
+import { useEditableCell } from './hooks/useCloseEditableCell';
import { useIsSoftFocusOnCurrentCell } from './hooks/useIsSoftFocusOnCurrentCell';
import { useSetSoftFocusOnCurrentCell } from './hooks/useSetSoftFocusOnCurrentCell';
+import { isEditModeScopedState } from './states/isEditModeScopedState';
+import { EditableCellDisplayMode } from './EditableCellDisplayMode';
+import { EditableCellEditMode } from './EditableCellEditMode';
+import { EditableCellSoftFocusMode } from './EditableCellSoftFocusMode';
+
+export const CellBaseContainer = styled.div`
+ align-items: center;
+ box-sizing: border-box;
+ cursor: pointer;
+ display: flex;
+ height: 32px;
+ position: relative;
+ user-select: none;
+ width: 100%;
+`;
type OwnProps = {
editModeContent: ReactElement;
@@ -18,16 +35,43 @@ export function EditableCell({
editModeContent,
nonEditModeContent,
}: OwnProps) {
+ const [isEditMode] = useRecoilScopedState(isEditModeScopedState);
+
const setSoftFocusOnCurrentCell = useSetSoftFocusOnCurrentCell();
+
+ const { closeEditableCell, openEditableCell } = useEditableCell();
+
+ // TODO: we might have silent problematic behavior because of the setTimeout in openEditableCell, investigate
+ // Maybe we could build a switchEditableCell to handle the case where we go from one cell to another.
+ // See https://github.com/twentyhq/twenty/issues/446
+ function handleOnClick() {
+ openEditableCell();
+ setSoftFocusOnCurrentCell();
+ }
+
+ function handleOnOutsideClick() {
+ closeEditableCell();
+ }
+
const hasSoftFocus = useIsSoftFocusOnCurrentCell();
+
return (
- <InplaceInput
- editModeHorizontalAlign={editModeHorizontalAlign}
- editModeVerticalPosition={editModeVerticalPosition}
- editModeContent={editModeContent}
- nonEditModeContent={nonEditModeContent}
- setSoftFocusOnCurrentInplaceInput={setSoftFocusOnCurrentCell}
- hasSoftFocus={!!hasSoftFocus}
- />
+ <CellBaseContainer onClick={handleOnClick}>
+ {isEditMode ? (
+ <EditableCellEditMode
+ editModeHorizontalAlign={editModeHorizontalAlign}
+ editModeVerticalPosition={editModeVerticalPosition}
+ onOutsideClick={handleOnOutsideClick}
+ >
+ {editModeContent}
+ </EditableCellEditMode>
+ ) : hasSoftFocus ? (
+ <EditableCellSoftFocusMode>
+ {nonEditModeContent}
+ </EditableCellSoftFocusMode>
+ ) : (
+ <EditableCellDisplayMode>{nonEditModeContent}</EditableCellDisplayMode>
+ )}
+ </CellBaseContainer>
);
}
diff --git a/front/src/modules/ui/components/inplace-input/InplaceInputDisplayMode.tsx b/front/src/modules/ui/components/editable-cell/EditableCellDisplayMode.tsx
similarity index 55%
rename from front/src/modules/ui/components/inplace-input/InplaceInputDisplayMode.tsx
rename to front/src/modules/ui/components/editable-cell/EditableCellDisplayMode.tsx
index f1c2510cbeb..fe9a3e0d929 100644
--- a/front/src/modules/ui/components/inplace-input/InplaceInputDisplayMode.tsx
+++ b/front/src/modules/ui/components/editable-cell/EditableCellDisplayMode.tsx
@@ -1,10 +1,12 @@
import styled from '@emotion/styled';
+import { useIsSoftFocusOnCurrentCell } from './hooks/useIsSoftFocusOnCurrentCell';
+
type Props = {
softFocus: boolean;
};
-export const InplaceInputNormalModeOuterContainer = styled.div<Props>`
+export const EditableCellNormalModeOuterContainer = styled.div<Props>`
align-items: center;
display: flex;
height: 100%;
@@ -22,7 +24,7 @@ export const InplaceInputNormalModeOuterContainer = styled.div<Props>`
: ''}
`;
-export const InplaceInputNormalModeInnerContainer = styled.div`
+export const EditableCellNormalModeInnerContainer = styled.div`
align-items: center;
display: flex;
height: 100%;
@@ -30,17 +32,16 @@ export const InplaceInputNormalModeInnerContainer = styled.div`
width: 100%;
`;
-export function InplaceInputDisplayMode({
+export function EditableCellDisplayMode({
children,
- hasSoftFocus,
-}: React.PropsWithChildren & {
- hasSoftFocus: boolean;
-}) {
+}: React.PropsWithChildren<unknown>) {
+ const hasSoftFocus = useIsSoftFocusOnCurrentCell();
+
return (
- <InplaceInputNormalModeOuterContainer softFocus={hasSoftFocus}>
- <InplaceInputNormalModeInnerContainer>
+ <EditableCellNormalModeOuterContainer softFocus={hasSoftFocus}>
+ <EditableCellNormalModeInnerContainer>
{children}
- </InplaceInputNormalModeInnerContainer>
- </InplaceInputNormalModeOuterContainer>
+ </EditableCellNormalModeInnerContainer>
+ </EditableCellNormalModeOuterContainer>
);
}
diff --git a/front/src/modules/ui/components/inplace-input/InplaceInputEditMode.tsx b/front/src/modules/ui/components/editable-cell/EditableCellEditMode.tsx
similarity index 79%
rename from front/src/modules/ui/components/inplace-input/InplaceInputEditMode.tsx
rename to front/src/modules/ui/components/editable-cell/EditableCellEditMode.tsx
index a28dd2efc93..79249bbe184 100644
--- a/front/src/modules/ui/components/inplace-input/InplaceInputEditMode.tsx
+++ b/front/src/modules/ui/components/editable-cell/EditableCellEditMode.tsx
@@ -6,9 +6,9 @@ import { useListenClickOutsideArrayOfRef } from '@/ui/hooks/useListenClickOutsid
import { useMoveSoftFocus } from '@/ui/tables/hooks/useMoveSoftFocus';
import { overlayBackground } from '@/ui/themes/effects';
-import { useInplaceInput } from './hooks/useCloseInplaceInput';
+import { useEditableCell } from './hooks/useCloseEditableCell';
-export const InplaceInputEditModeContainer = styled.div<OwnProps>`
+export const EditableCellEditModeContainer = styled.div<OwnProps>`
align-items: center;
border: 1px solid ${({ theme }) => theme.border.color.light};
border-radius: ${({ theme }) => theme.border.radius.sm};
@@ -34,7 +34,7 @@ type OwnProps = {
onOutsideClick?: () => void;
};
-export function InplaceInputEditMode({
+export function EditableCellEditMode({
editModeHorizontalAlign,
editModeVerticalPosition,
children,
@@ -42,7 +42,7 @@ export function InplaceInputEditMode({
}: OwnProps) {
const wrapperRef = useRef(null);
- const { closeInplaceInput } = useInplaceInput();
+ const { closeEditableCell } = useEditableCell();
const { moveRight, moveLeft, moveDown } = useMoveSoftFocus();
useListenClickOutsideArrayOfRef([wrapperRef], () => {
@@ -52,7 +52,7 @@ export function InplaceInputEditMode({
useHotkeys(
'enter',
() => {
- closeInplaceInput();
+ closeEditableCell();
moveDown();
},
{
@@ -60,26 +60,26 @@ export function InplaceInputEditMode({
enableOnFormTags: true,
preventDefault: true,
},
- [closeInplaceInput],
+ [closeEditableCell],
);
useHotkeys(
'esc',
() => {
- closeInplaceInput();
+ closeEditableCell();
},
{
enableOnContentEditable: true,
enableOnFormTags: true,
preventDefault: true,
},
- [closeInplaceInput],
+ [closeEditableCell],
);
useHotkeys(
'tab',
() => {
- closeInplaceInput();
+ closeEditableCell();
moveRight();
},
{
@@ -87,13 +87,13 @@ export function InplaceInputEditMode({
enableOnFormTags: true,
preventDefault: true,
},
- [closeInplaceInput, moveRight],
+ [closeEditableCell, moveRight],
);
useHotkeys(
'shift+tab',
() => {
- closeInplaceInput();
+ closeEditableCell();
moveLeft();
},
{
@@ -101,17 +101,17 @@ export function InplaceInputEditMode({
enableOnFormTags: true,
preventDefault: true,
},
- [closeInplaceInput, moveRight],
+ [closeEditableCell, moveRight],
);
return (
- <InplaceInputEditModeContainer
- data-testid="inplace-input-edit-mode-container"
+ <EditableCellEditModeContainer
+ data-testid="editable-cell-edit-mode-container"
ref={wrapperRef}
editModeHorizontalAlign={editModeHorizontalAlign}
editModeVerticalPosition={editModeVerticalPosition}
>
{children}
- </InplaceInputEditModeContainer>
+ </EditableCellEditModeContainer>
);
}
diff --git a/front/src/modules/ui/components/inplace-input/InplaceInputSoftFocusMode.tsx b/front/src/modules/ui/components/editable-cell/EditableCellSoftFocusMode.tsx
similarity index 71%
rename from front/src/modules/ui/components/inplace-input/InplaceInputSoftFocusMode.tsx
rename to front/src/modules/ui/components/editable-cell/EditableCellSoftFocusMode.tsx
index 02681d20449..d67da443afd 100644
--- a/front/src/modules/ui/components/inplace-input/InplaceInputSoftFocusMode.tsx
+++ b/front/src/modules/ui/components/editable-cell/EditableCellSoftFocusMode.tsx
@@ -5,13 +5,13 @@ import { useRecoilState } from 'recoil';
import { captureHotkeyTypeInFocusState } from '@/hotkeys/states/captureHotkeyTypeInFocusState';
import { isNonTextWritingKey } from '@/utils/hotkeys/isNonTextWritingKey';
-import { useInplaceInput } from './hooks/useCloseInplaceInput';
-import { InplaceInputDisplayMode } from './InplaceInputDisplayMode';
+import { useEditableCell } from './hooks/useCloseEditableCell';
+import { EditableCellDisplayMode } from './EditableCellDisplayMode';
-export function InplaceInputSoftFocusMode({
+export function EditableCellSoftFocusMode({
children,
}: React.PropsWithChildren<unknown>) {
- const { closeInplaceInput, openInplaceInput } = useInplaceInput();
+ const { closeEditableCell, openEditableCell } = useEditableCell();
const [captureHotkeyTypeInFocus] = useRecoilState(
captureHotkeyTypeInFocusState,
);
@@ -19,14 +19,14 @@ export function InplaceInputSoftFocusMode({
useHotkeys(
'enter',
() => {
- openInplaceInput();
+ openEditableCell();
},
{
enableOnContentEditable: true,
enableOnFormTags: true,
preventDefault: true,
},
- [closeInplaceInput],
+ [closeEditableCell],
);
useHotkeys(
@@ -44,7 +44,7 @@ export function InplaceInputSoftFocusMode({
if (captureHotkeyTypeInFocus) {
return;
}
- openInplaceInput();
+ openEditableCell();
},
{
enableOnContentEditable: true,
@@ -53,7 +53,5 @@ export function InplaceInputSoftFocusMode({
},
);
- return (
- <InplaceInputDisplayMode hasSoftFocus>{children}</InplaceInputDisplayMode>
- );
+ return <EditableCellDisplayMode>{children}</EditableCellDisplayMode>;
}
diff --git a/front/src/modules/ui/components/editable-cell/HoverableMenuItem.tsx b/front/src/modules/ui/components/editable-cell/HoverableMenuItem.tsx
new file mode 100644
index 00000000000..b753f80d807
--- /dev/null
+++ b/front/src/modules/ui/components/editable-cell/HoverableMenuItem.tsx
@@ -0,0 +1,19 @@
+import styled from '@emotion/styled';
+
+export const HoverableMenuItem = styled.div`
+ align-items: center;
+ background: ${({ theme }) => theme.background.primary};
+ border-radius: 4px;
+ box-sizing: border-box;
+ cursor: pointer;
+ display: flex;
+ height: 100%;
+ position: relative;
+ transition: background 0.1s ease;
+ user-select: none;
+ width: 100%;
+
+ &:hover {
+ background: ${({ theme }) => theme.background.transparent.light};
+ }
+`;
diff --git a/front/src/modules/ui/components/inplace-input/hooks/useCloseInplaceInput.ts b/front/src/modules/ui/components/editable-cell/hooks/useCloseEditableCell.ts
similarity index 81%
rename from front/src/modules/ui/components/inplace-input/hooks/useCloseInplaceInput.ts
rename to front/src/modules/ui/components/editable-cell/hooks/useCloseEditableCell.ts
index 534800bed27..c2cc3b4e833 100644
--- a/front/src/modules/ui/components/inplace-input/hooks/useCloseInplaceInput.ts
+++ b/front/src/modules/ui/components/editable-cell/hooks/useCloseEditableCell.ts
@@ -1,15 +1,14 @@
import { useRecoilCallback } from 'recoil';
import { useRecoilScopedState } from '@/recoil-scope/hooks/useRecoilScopedState';
-// TODO: Remove dependancy to table
import { isSomeInputInEditModeState } from '@/ui/tables/states/isSomeInputInEditModeState';
import { isEditModeScopedState } from '../states/isEditModeScopedState';
-export function useInplaceInput() {
+export function useEditableCell() {
const [, setIsEditMode] = useRecoilScopedState(isEditModeScopedState);
- const closeInplaceInput = useRecoilCallback(
+ const closeEditableCell = useRecoilCallback(
({ set }) =>
async () => {
setIsEditMode(false);
@@ -21,7 +20,7 @@ export function useInplaceInput() {
[setIsEditMode],
);
- const openInplaceInput = useRecoilCallback(
+ const openEditableCell = useRecoilCallback(
({ snapshot, set }) =>
() => {
const isSomeInputInEditMode = snapshot
@@ -38,7 +37,7 @@ export function useInplaceInput() {
);
return {
- closeInplaceInput,
- openInplaceInput,
+ closeEditableCell,
+ openEditableCell,
};
}
diff --git a/front/src/modules/ui/components/inplace-input/states/isCreateModeScopedState.ts b/front/src/modules/ui/components/editable-cell/states/isCreateModeScopedState.ts
similarity index 100%
rename from front/src/modules/ui/components/inplace-input/states/isCreateModeScopedState.ts
rename to front/src/modules/ui/components/editable-cell/states/isCreateModeScopedState.ts
diff --git a/front/src/modules/ui/components/inplace-input/states/isEditModeScopedState.ts b/front/src/modules/ui/components/editable-cell/states/isEditModeScopedState.ts
similarity index 100%
rename from front/src/modules/ui/components/inplace-input/states/isEditModeScopedState.ts
rename to front/src/modules/ui/components/editable-cell/states/isEditModeScopedState.ts
diff --git a/front/src/modules/ui/components/inplace-input/types/InplaceTextInput.tsx b/front/src/modules/ui/components/editable-cell/types/EditableText.tsx
similarity index 77%
rename from front/src/modules/ui/components/inplace-input/types/InplaceTextInput.tsx
rename to front/src/modules/ui/components/editable-cell/types/EditableText.tsx
index 48553e4fc33..aeea86426de 100644
--- a/front/src/modules/ui/components/inplace-input/types/InplaceTextInput.tsx
+++ b/front/src/modules/ui/components/editable-cell/types/EditableText.tsx
@@ -3,15 +3,13 @@ import styled from '@emotion/styled';
import { textInputStyle } from '@/ui/themes/effects';
-import { InplaceInput } from '../InplaceInput';
+import { EditableCell } from '../EditableCell';
type OwnProps = {
placeholder?: string;
content: string;
changeHandler: (updated: string) => void;
editModeHorizontalAlign?: 'left' | 'right';
- setSoftFocusOnCurrentInplaceInput?: () => void;
- hasSoftFocus?: boolean;
};
// TODO: refactor
@@ -28,19 +26,17 @@ const StyledNoEditText = styled.div`
width: 100%;
`;
-export function InplaceTextInput({
+export function EditableText({
content,
placeholder,
changeHandler,
editModeHorizontalAlign,
- setSoftFocusOnCurrentInplaceInput,
- hasSoftFocus,
}: OwnProps) {
const inputRef = useRef<HTMLInputElement>(null);
const [inputValue, setInputValue] = useState(content);
return (
- <InplaceInput
+ <EditableCell
editModeHorizontalAlign={editModeHorizontalAlign}
editModeContent={
<StyledInplaceInput
@@ -54,9 +50,7 @@ export function InplaceTextInput({
}}
/>
}
- setSoftFocusOnCurrentInplaceInput={setSoftFocusOnCurrentInplaceInput}
- hasSoftFocus={hasSoftFocus}
nonEditModeContent={<StyledNoEditText>{inputValue}</StyledNoEditText>}
- ></InplaceInput>
+ ></EditableCell>
);
}
diff --git a/front/src/modules/ui/components/editable-cell/types/EditableTextCell.tsx b/front/src/modules/ui/components/editable-cell/types/EditableTextCell.tsx
deleted file mode 100644
index 138be06a396..00000000000
--- a/front/src/modules/ui/components/editable-cell/types/EditableTextCell.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { InplaceTextInput } from '../../inplace-input/types/InplaceTextInput';
-import { useIsSoftFocusOnCurrentCell } from '../hooks/useIsSoftFocusOnCurrentCell';
-import { useSetSoftFocusOnCurrentCell } from '../hooks/useSetSoftFocusOnCurrentCell';
-
-type OwnProps = {
- placeholder?: string;
- content: string;
- changeHandler: (updated: string) => void;
- editModeHorizontalAlign?: 'left' | 'right';
-};
-
-export function EditableTextCell({
- editModeHorizontalAlign = 'left',
- content,
- changeHandler,
- placeholder,
-}: OwnProps) {
- const setSoftFocusOnCurrentCell = useSetSoftFocusOnCurrentCell();
- const hasSoftFocus = useIsSoftFocusOnCurrentCell();
- return (
- <InplaceTextInput
- editModeHorizontalAlign={editModeHorizontalAlign}
- content={content}
- changeHandler={changeHandler}
- placeholder={placeholder}
- setSoftFocusOnCurrentInplaceInput={setSoftFocusOnCurrentCell}
- hasSoftFocus={hasSoftFocus}
- />
- );
-}
diff --git a/front/src/modules/ui/components/inplace-input/InplaceInput.tsx b/front/src/modules/ui/components/inplace-input/InplaceInput.tsx
deleted file mode 100644
index 812c2c7e487..00000000000
--- a/front/src/modules/ui/components/inplace-input/InplaceInput.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { ReactElement } from 'react';
-import styled from '@emotion/styled';
-
-import { useRecoilScopedState } from '@/recoil-scope/hooks/useRecoilScopedState';
-
-import { useInplaceInput } from './hooks/useCloseInplaceInput';
-import { isEditModeScopedState } from './states/isEditModeScopedState';
-import { InplaceInputDisplayMode } from './InplaceInputDisplayMode';
-import { InplaceInputEditMode } from './InplaceInputEditMode';
-import { InplaceInputSoftFocusMode } from './InplaceInputSoftFocusMode';
-
-export const InplaceInputBaseContainer = styled.div`
- align-items: center;
- box-sizing: border-box;
- cursor: pointer;
- display: flex;
- height: 32px;
- position: relative;
- user-select: none;
- width: 100%;
-`;
-
-type OwnProps = {
- editModeContent: ReactElement;
- nonEditModeContent: ReactElement;
- editModeHorizontalAlign?: 'left' | 'right';
- editModeVerticalPosition?: 'over' | 'below';
- setSoftFocusOnCurrentInplaceInput?: () => void;
- hasSoftFocus?: boolean;
-};
-
-export function InplaceInput({
- editModeHorizontalAlign = 'left',
- editModeVerticalPosition = 'over',
- editModeContent,
- nonEditModeContent,
- setSoftFocusOnCurrentInplaceInput,
- hasSoftFocus,
-}: OwnProps) {
- const [isEditMode] = useRecoilScopedState(isEditModeScopedState);
-
- const { closeInplaceInput, openInplaceInput } = useInplaceInput();
-
- // TODO: we might have silent problematic behavior because of the setTimeout in openInplaceInput, investigate
- // Maybe we could build a switchInplaceInput to handle the case where we go from one InplaceInput to another.
- // See https://github.com/twentyhq/twenty/issues/446
- function handleOnClick() {
- openInplaceInput();
- setSoftFocusOnCurrentInplaceInput && setSoftFocusOnCurrentInplaceInput();
- }
-
- function handleOnOutsideClick() {
- closeInplaceInput();
- }
- return (
- <InplaceInputBaseContainer onClick={handleOnClick}>
- {isEditMode ? (
- <InplaceInputEditMode
- editModeHorizontalAlign={editModeHorizontalAlign}
- editModeVerticalPosition={editModeVerticalPosition}
- onOutsideClick={handleOnOutsideClick}
- >
- {editModeContent}
- </InplaceInputEditMode>
- ) : hasSoftFocus ? (
- <InplaceInputSoftFocusMode>
- {nonEditModeContent}
- </InplaceInputSoftFocusMode>
- ) : (
- <InplaceInputDisplayMode hasSoftFocus={!!hasSoftFocus}>
- {nonEditModeContent}
- </InplaceInputDisplayMode>
- )}
- </InplaceInputBaseContainer>
- );
-}
diff --git a/front/src/pages/companies/companies-columns.tsx b/front/src/pages/companies/companies-columns.tsx
index d5536df8d12..1374e8e03e3 100644
--- a/front/src/pages/companies/companies-columns.tsx
+++ b/front/src/pages/companies/companies-columns.tsx
@@ -4,7 +4,7 @@ import { createColumnHelper } from '@tanstack/react-table';
import { CompanyAccountOwnerCell } from '@/companies/components/CompanyAccountOwnerCell';
import { CompanyEditableNameChipCell } from '@/companies/components/CompanyEditableNameCell';
import { EditableDate } from '@/ui/components/editable-cell/types/EditableDate';
-import { EditableTextCell } from '@/ui/components/editable-cell/types/EditableTextCell';
+import { EditableText } from '@/ui/components/editable-cell/types/EditableText';
import { ColumnHead } from '@/ui/components/table/ColumnHead';
import {
IconBuildingSkyscraper,
@@ -44,7 +44,7 @@ export const useCompaniesColumns = () => {
<ColumnHead viewName="URL" viewIcon={<IconLink size={16} />} />
),
cell: (props) => (
- <EditableTextCell
+ <EditableText
content={props.row.original.domainName || ''}
placeholder="Domain name"
changeHandler={(value) => {
@@ -66,7 +66,7 @@ export const useCompaniesColumns = () => {
<ColumnHead viewName="Employees" viewIcon={<IconUsers size={16} />} />
),
cell: (props) => (
- <EditableTextCell
+ <EditableText
content={props.row.original.employees?.toString() || ''}
placeholder="Employees"
changeHandler={(value) => {
@@ -89,7 +89,7 @@ export const useCompaniesColumns = () => {
<ColumnHead viewName="Address" viewIcon={<IconMap size={16} />} />
),
cell: (props) => (
- <EditableTextCell
+ <EditableText
content={props.row.original.address || ''}
placeholder="Address"
changeHandler={(value) => {
diff --git a/front/src/pages/people/__stories__/People.inputs.stories.tsx b/front/src/pages/people/__stories__/People.inputs.stories.tsx
index 0356f6c015c..7355c3a6e6e 100644
--- a/front/src/pages/people/__stories__/People.inputs.stories.tsx
+++ b/front/src/pages/people/__stories__/People.inputs.stories.tsx
@@ -39,13 +39,13 @@ export const InteractWithManyRows: Story = {
);
expect(
- canvas.queryByTestId('inplace-input-edit-mode-container'),
+ canvas.queryByTestId('editable-cell-edit-mode-container'),
).toBeNull();
await userEvent.click(firstRowEmailCell);
expect(
- canvas.queryByTestId('inplace-input-edit-mode-container'),
+ canvas.queryByTestId('editable-cell-edit-mode-container'),
).toBeInTheDocument();
await userEvent.click(secondRowEmailCell);
@@ -57,7 +57,7 @@ export const InteractWithManyRows: Story = {
);
expect(
- canvas.queryByTestId('inplace-input-edit-mode-container'),
+ canvas.queryByTestId('editable-cell-edit-mode-container'),
).toBeNull();
await userEvent.click(secondRowEmailCellFocused);
@@ -65,7 +65,7 @@ export const InteractWithManyRows: Story = {
await sleep(25);
expect(
- canvas.queryByTestId('inplace-input-edit-mode-container'),
+ canvas.queryByTestId('editable-cell-edit-mode-container'),
).toBeInTheDocument();
},
parameters: {
diff --git a/front/src/pages/people/people-columns.tsx b/front/src/pages/people/people-columns.tsx
index a69bb885ee6..3c9ee46c653 100644
--- a/front/src/pages/people/people-columns.tsx
+++ b/front/src/pages/people/people-columns.tsx
@@ -5,7 +5,7 @@ import { EditablePeopleFullName } from '@/people/components/EditablePeopleFullNa
import { PeopleCompanyCell } from '@/people/components/PeopleCompanyCell';
import { EditableDate } from '@/ui/components/editable-cell/types/EditableDate';
import { EditablePhone } from '@/ui/components/editable-cell/types/EditablePhone';
-import { EditableTextCell } from '@/ui/components/editable-cell/types/EditableTextCell';
+import { EditableText } from '@/ui/components/editable-cell/types/EditableText';
import { ColumnHead } from '@/ui/components/table/ColumnHead';
import {
IconBuildingSkyscraper,
@@ -55,7 +55,7 @@ export const usePeopleColumns = () => {
<ColumnHead viewName="Email" viewIcon={<IconMail size={16} />} />
),
cell: (props) => (
- <EditableTextCell
+ <EditableText
placeholder="Email"
content={props.row.original.email || ''}
changeHandler={async (value: string) => {
@@ -137,7 +137,7 @@ export const usePeopleColumns = () => {
<ColumnHead viewName="City" viewIcon={<IconMap size={16} />} />
),
cell: (props) => (
- <EditableTextCell
+ <EditableText
editModeHorizontalAlign="right"
placeholder="City"
content={props.row.original.city || ''}